Re: Sorting question
- To: mathgroup at smc.vnet.net
- Subject: [mg52782] Re: [mg52758] Sorting question
- From: yehuda ben-shimol <benshimo at bgu.ac.il>
- Date: Mon, 13 Dec 2004 04:22:33 -0500 (EST)
- References: <200412111023.FAA06589@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
call your data list l so Sort[Cases[l,{x_,x_}]] will do the work The Cases pick up only pair of equal element and the Sort sorts them. The default sorting mechanism of Sort is sufficient for your needs. yehuda Nimrod wrote: > A simple sorting question that has me stumped as to how to do it both >quickly and elegantly. > >I have a list of data pairs of the form (distance, time). I want to >sort on the distance element and then remove all pairs where the time >element is out of order with the distance element. For example >((1,1),(2,3),(3,2),(4,4)) --> ((1,1),(4,4)). The actual lists are >much longer. > >Thanks in advnace, > >Nimrod. > > >
- References:
- Sorting question
- From: Nimrod <jdedguard-agent@yahoo.co.uk>
- Sorting question