Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sorting by multiple columns

Status
Not open for further replies.

howdthattaste

Programmer
Apr 12, 2007
17
US
hello,
maybe its just me, (well im pretty sure its just me) but i'm having a hard time trying to figure out the best way to sort a particular text file.

sample race data:
(name,sex,state,secs)
Sally,female,indiana,26,23443
Mike,male,ohio,23,23423
Jim,male,indiana,29,12355
etc...

so lets say the complete data had almost every state present and ages 20 - 29 with a mix of boys/girls. i want to sort by: state, age, sex, seconds, name. Sure in excel, this is easy, but additionally, i want to export only the top in each category to a file. (basically the winners to a file).

so the results like:
Alabama, 29, Female, [time], [name]
Alabama, 29, Male, [time], [name]
Alabama, 28, Female, [time],[name]
etc..

so there might be 80,000 racers, but i only need the top in each category. However, i want to throw in that maybe no females age 23 from Maine participated. so there would be no line in the output file for that. (so yeah, for this example, if there is a tie, first name wins, and thats fine.)

so im not sure where to start because i notice that some columns i wanted sort ascending (state/time/sex/name), and some descending (age)

many thanks in advance!


"Not New York, Kansas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top