sorting 2 dimension array

August 5, 2010 at 10:10:46
Specs: unix
Hi there,

Can someone let me know how to sort the 2 dimensional array below by column 1 then by column 2?

22 55
2222 2230
33 66
44 58
222 240
11 25
22 60
33 45

output:
11 25
22 55
22 60
33 45
33 66
44 58
222 240
2222 2230

Please note that this is a small part in my awk script. the input data is not in file, but it was manipulated in my script.

Could you suggest a code to solve this?

Thanks,
Phoebe


See More: sorting 2 dimension array

Report •

#1
August 20, 2010 at 10:12:36
Since you're running on some flavor of Unix, why not use sort? I'm assuming that these columns of numbers are in (or can be put into) text files. You may have to sort twice: on column 2, and then on column 1. man sort to get the details on usage.

Report •

#2
August 20, 2010 at 22:25:07

Report •
Related Solutions


Ask Question