Ibrahim,

On Sat, 13 Jun 1998, Ibrahim F Haddad wrote:

> Given a file that contains data of the following format:

> 7.606565 5.404950
> 4.969272 4.597600
> 4.969272 4.597600
> 2.400000 3.486746
> 3.000000 3.672252
> 3.600000 3.766663

> How to sort it in increasing order of the x column so
> after sorting it looks like that:

> 2.400000 3.486746
> 3.000000 3.672252
> 3.600000 3.766663
> 4.969272 4.597600
> 4.969272 4.597600
> 7.606565 5.404950

> please note that duplicate entries may exist.

qsort(3) does what you need.  You control the behavior of qsort by
passing to it a pointer to a comparison function.  The Libc info pages
contain a qsort(3) example.

        -Walid

==================================================================
Walid Keirouz                     Computer Science---Byblos Campus
E-mail: [EMAIL PROTECTED]          Lebanese American University
Tel:    +961 (9) 547-254 x2361    475 Riverside Drive #1846
Fax:    +961 (9) 944-851          New York, NY 10115


Reply via email to