in reply to sorting an array of an arrays
As for the sorting algorithm, the most common approach would be something like this:use Data::Dumper; my @array = (); $array[0] = [1]; $array[2] = [2]; @array = sort { $$a[0] cmp $$b[0]} @array; print Dumper \@array;
As for the problem you are solving, it would probably be faster and easier to handle the sorting in a database, where the book information should probably be stored. Good luck with the project, I'll stop by your store next time I'm in Amherst :)use strict; use warnings; use Data::Dumper; my @courselist = ( ["UM", "CS 34", ], ["AC", "PHIL 13", ], ["UM", 'BIO 567', ], ["UA", 'BIO 999', ], ["UM", 'BIO 1', ], ); @courselist = sort {$$a[0] cmp $$b[0] or $$a[1] cmp $$b[1]} @courselis +t; print Dumper(\@courselist);
|
|---|