I want to sort the above array of hashes based on multiple keys in hashes. i.e., If I do a sort as key1-ASC, key2-DSC, the output of the above array should be like this@array = ( {'key1' ==> 'abc', 'key2' ==> '111', 'key3' ==> 'abcdef'}, {'key1' ==> 'acc', 'key2' ==> '101', 'key3' ==> 'abcdef'}, {'key1' ==> 'acc', 'key2' ==> '1000', 'key3' ==> 'abcdef'}, {'key1' ==> 'abc', 'key2' ==> '112', 'key3' ==> 'abcdef'} )
Hope the above illustration is understandable. This kind of multi-column sorting is already available in MsExcel. i.e., if we have data in 2 columns and then sort them by specifying - "sort first column in ascending" and "sort second column in descending", it will give the above output. Please let know, if this can be done in PERL. Thanks in advance. Mani.{'key1' ==> 'abc', 'key2' ==> '112', 'key3' ==> 'abcdef'}, {'key1' ==> 'abc', 'key2' ==> '111', 'key3' ==> 'abcdef'}, {'key1' ==> 'acc', 'key2' ==> '1000', 'key3' ==> 'abcdef'}, {'key1' ==> 'acc', 'key2' ==> '101', 'key3' ==> 'abcdef'}
In reply to MsExcel like Multi Column Sorting by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |