Message Boards Message Boards

0
|
2425 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Dataset: Sort the rows by theire values

Posted 10 years ago

Hi everyone,

I am new in the mathematica community and I have a probably easy question for you regarding how to sort a dataset as the following so that I have sorted the values in the fist row descending from 44 in the first line down to 3 in the last one.

dataset = Dataset[{ <|"a" -> 6, "b" -> "x", "c" -> {1}|>, <|"a" -> 8, "b" -> "y", "c" -> {2, 3}|>, <|"a" -> 44, "b" -> "z", "c" -> {3}|>, <|"a" -> 4, "b" -> "x", "c" -> {4, 5}|>, <|"a" -> 5, "b" -> "y", "c" -> {5, 6, 7}|>, <|"a" -> 3, "b" -> "z", "c" -> {}|>}]

Many thanks for your support and best regards

POSTED BY: Hans Meier
2 Replies

Hi,

you can easily sort the underlying association:

Reverse@Sort[dataset // Normal] // Dataset

enter image description here

Alternatively,

Sort[dataset][Reverse]

should work.

Cheers,

M.

POSTED BY: Marco Thiel
Posted 10 years ago

Perfect! Thank you very much for your quick response!

POSTED BY: Hans Meier
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract