Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • Nice work. What if the attributes should be sorted in different orders? Suppose attrA should be sorted ascending and attrB descending? Is there a quick solution on top of this? Thanks!
    – mhn_namak
    Commented Feb 3, 2020 at 22:18
  • @mhn_namak see stackoverflow.com/a/55866810/2359945 which is a beautiful way to sort on n criteria, each in either ascending or descending. Commented Feb 9, 2021 at 13:03
  • We clearly have very different views on beautiful. While it does the job that is fugliest thing I have ever seen. And the efficiency becomes a function of (n*m) where m is number of attributes to sort on instead of just a function of the length of the list. i would think other answers here have better solutions or you could write your own sort function to do it yourself if you really needed that behavior
    – UpAndAdam
    Commented Feb 18, 2021 at 19:59