Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Date to be sorted in descending and time in ascending

by kcott (Canon)
on May 18, 2012 at 09:48 UTC ( #971257=note: print w/replies, xml ) Need Help??


in reply to Date to be sorted in descending and time in ascending

The basic technique for sorting on multiple columns in a set of records (an array of arrays) is:

my $primary_sort_column = n; my $secondary_sort_column = n; my $tertiary_sort_column = n; my @sorted_records = sort { $a->[$primary_sort_column] op $b->[$primary_sort_column]; || $a->[$secondary_sort_column] op $b->[$secondary_sort_column]; || $a->[$tertiary_sort_column] op $b->[$tertiary_sort_column]; ) @unsorted_records;

n is an integer; op is typically cmp (lexical ordering) or the spaceship operator <=> (numeric ordering)

Take a look at sort for details.

-- Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://971257]
help
Chatterbox?
[choroba]: It has the widest rear seats space available in the same price category - needed for the 3 kids.
Discipulus families growth is related to price of cars nowadays..
[choroba]: price of anything, unfortunately
[Discipulus]: yes, unfortunately.
[Corion]: Discipulus: you can "easily" trap shutdown/logoff in a Win32::GUI application by capturing and responding to the appropriate message
[LanX]: choroba wants to scale further? :)
[Discipulus]: I read an article about how much the female condition has got worst in the eastern europe after the fall of social policies
LanX has a friend in Berlin who switched to go(lang) and just got a kid ...
[marto]: good morning all

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2017-01-17 09:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (154 votes). Check out past polls.