On Jul 13, Beast said:

Jeff 'japhy' Pinyan wrote:

Is there any builtin function in perl to sort the above array based on uid, username or fulname?

There is a built-in function to sort a list, yes. But the mechanism by which to sort the list is, in this case, up to you to provide. This works:

  my @sorted = sort {
    $a->[0] <=> $b->[0]
  } @employees;


However, is this scalable if, for example list is more than 5000 ?

Sure, it's scalable... I believe perl uses a mergesort nowadays, which is better on larger lists anyway. Regardless, given the data you showed us, this is the simplest and shortest (and most likely fastest) way to sort it based on a given index.

--
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %    -- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to