       Re: Sorting question

• To: mathgroup at smc.vnet.net
• Subject: [mg52772] Re: Sorting question
• From: "Dr. Wolfgang Hintze" <weh at snafu.de>
• Date: Mon, 13 Dec 2004 04:22:13 -0500 (EST)
• References: <cpeko6\$764\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

Assuming that "out of order with" means unequal here's an approach using
Select.

Let your list be

In:=
d = {{1, 1}, {2, 3}, {3, 2}, {4, 4}}

Out=
{{1, 1}, {2, 3}, {3, 2}, {4, 4}}

Then

In:=
s = Select[d, #1[] == #1[] & ]

Out=
{{1, 1}, {4, 4}}

Hope this helps.
Wolfgang

"out of order with"

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.
>
>

• Prev by Date: Re: Sorting question
• Next by Date: Re: problem getting the area under a parmetric curve
• Previous by thread: Re: Sorting question
• Next by thread: Re: Sorting question