# Dataset - Sort in Highest to Lowest Order

Posted 9 years ago
7600 Views
|
3 Replies
|
5 Total Likes
|
 Hi all,Where dataset is a Dataset with plenty of rows and several attributes, and AttributeName is exactly that, this... dataset[SortBy["AttributeName"]] ...sorts my dataset entries in lowest to highest order by AttributeName.I cannot seem to find any way to sort in the reverse order.Thanks in advanceBrad
3 Replies
Sort By:
Posted 9 years ago
 Thanks, VitaliyI will admit I had considered this, but assumed there must be a more efficient way other than sorting then reversing. But now I wonder if I misunderstand the syntax: does the [Reverse] keyword simply cause the initial sort to be in reverse order, or does the process actually involve first sorting, then reversing?Likewise, perhaps I misunderstand the magic that is Dataset -- perhaps Reverse is a much more efficient operation than it sounds.
Posted 9 years ago
 Depends on the order of operations, non-commutator operations in general: titanic = ExampleData[{"Dataset", "Titanic"}]; In[22]:= (titanic[SortBy["age"]] // Normal) == (titanic[Reverse][SortBy["age"]] // Normal) Out[22]= True In[23]:= (titanic[SortBy["age"]][Reverse] // Normal) == (titanic[Reverse][SortBy["age"]] // Normal) Out[23]= False 
Posted 9 years ago
 You can then Reverse all set: planets = ExampleData[{"Dataset", "Planets"}]; planets[SortBy["Mass"], "Mass"][Reverse] 
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments