1

Say we have a list:

```
{{1/2, -(Sqrt[3]/2)}, {1, 0}, {1/2, Sqrt[3]/2}, {-(1/2), Sqrt[3]/2}, {-1, 0}, {-(1/2), -(Sqrt[3]/2)}}
```

now we want to sort that list by looking at the second component of each sub list (call it y coordinate for ease), i.e. sort it s.t. y is in the descending order. So we'd get

```
{{1/2, Sqrt[3]/2},{-1/2, Sqrt[3]/2},{1,0},{-1,0},{1/2,-(Sqrt[3]/2)},{-1/2,-(Sqrt[3]/2)}}
```

And yeah, I should mention that if there are more than one sub lists with equal y, we would additionally (sub)sort them by descending x (first component in each of the sub lists).

I tried to use SortBy, in different forms, but I don't seem to be able to figure it out by myself. I'd appreciate any help.

2"I tried to use SortBy" What did you try, specifically? – Szabolcs – 2019-02-13T13:57:29.007

2

Likely a duplicate of https://mathematica.stackexchange.com/q/2729/12

– Szabolcs – 2019-02-13T13:59:01.003Thanks for that link @Szabolcs.

`Reverse[SortBy[list, N[Last]]]`

seems to be doing the job. – amator2357 – 2019-02-13T14:12:59.867Not sure why and how in the case of those sub lists that have equal y component it puts those with the greater x first... – amator2357 – 2019-02-13T14:18:33.587

Just realized that

`Reverse[SortBy[list, N[Last]]]`

doesn't actually work. – amator2357 – 2019-02-13T14:24:56.8433Try

`SortBy[list, N[-Last[#]]&]`

instead. – Sjoerd Smit – 2019-02-13T14:25:53.7901You did not say what you tried originally.

`N[Last]`

is not a function, so it's not appropriate here. Use`N@*Last`

or`N[Last[#]]&`

. – Szabolcs – 2019-02-13T14:26:05.2101@amator, if you've figured it out from the comments, you can answer your own question. Helps the silent majority of lurkers develop their knowledge too. – MikeY – 2019-02-13T14:51:43.460