| View previous topic :: View next topic |
| Author |
Message |
FallFromGrace Voice
Joined: 28 Jul 2008 Posts: 17
|
Posted: Tue Aug 12, 2008 11:13 am Post subject: lsort - need two-pass sort :O |
|
|
i have a list with such elements:
{kelly 15 1}
{john 50 4}
{jack 80 2}
{bill 70 3}
{ann 30 2}
{james 100 1}
so i need to sort it, to get:
{john 50 4}
{bill 70 3}
{jack 80 2}
{ann 30 2}
{james 100 1}
{kelly 15 1}
with first sort by 3th value and second sort by 2th value..
maximum that i can get is a list sorted by 2th or 3th value... [lsort -index 1 or 2 -decreasing $list]
how to sort it again? |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Aug 12, 2008 11:49 am Post subject: |
|
|
lsort uses a merge-sort, and depending on the merge-algorithm, you might be able to get away with something like this:
| Code: | | set newlist [lsort -index 2 -decreasing [lsort -index 1 -decreasing $list]] |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
FallFromGrace Voice
Joined: 28 Jul 2008 Posts: 17
|
Posted: Tue Aug 12, 2008 7:49 pm Post subject: |
|
|
it works ^^
tnx you ) |
|
| Back to top |
|
 |
|