bill@unixland.uucp (Bill Heiser) (11/19/90)
I'm writing a program for a C class, and am looking for tips on how to sort an array of structures. I understand how to sort a normal array, but I'm unsure of this one... (it's due in a couple of days, but I'm working hard to finish it :-) The structure looks like this: #define NUMFLIGHTS 100 #define NUMPASSENGERS 500 struct p_rec { char name[50]; int seats; }; struct flight { int flight_num; int seats_left; struct p_rec passenger[NUMPASSENGERS]; } flight[NUMFLIGHTS]; I need to print a list of available seats, sorted in order by flight number. I guess somehow I need to sort the structure based on the contents of flight_num. In a different part of the program, I need to sort the passenger list for a specific flight. I guess in that case I need to get to the right flight number, then sort the p_rec structure on name. Any hints/clues/suggestions would be appreciated, especially if they're before Monday night :-) (it is due on Tuesday). bill -- home: ...!{uunet,bloom-beacon,esegue}!world!unixland!bill bill@unixland.uucp, bill%unixland.uucp@world.std.com Public Access Unix - Esix SYSVR3 - (508) 655-3848 other: heiser@world.std.com Public Access Unix (617) 739-9753