Re: Excel Type Sorting ???



On Feb 15, 2008 1:36 PM, <ezsuperkev@xxxxxxxxx> wrote:

I'm trying to figure out how to do an Excel type sort in Perl but
can't seem to find anything on specifically what I want to do. So here
goes.

I think you want to sort on multiple criteria, with nothing "Excel" about it.

Imagine 3 columns of numbers: A, B, C.

I want to sort in descending order starting with Column A then Column
B, and then Column C.

Thing is I don't want the order of A to change when sorting B and i
don't want the order of A or B to change when sorting C.

So you sort on criterion A. When that's a tie, you go on to use
criterion B, then finally C. That's just a single sort operation,
using a sort sub something like this:

sub sort_by_ABC {
$a->{A} cmp $b->{A} or
$a->{B} cmp $b->{B} or
$a->{C} cmp $b->{C}
}

Of course, that's probably not the way your criteria are stored, but
it should give you the general idea.

http://perldoc.perl.org/functions/sort.html

Good luck with it!

--Tom Phoenix
Stonehenge Perl Training
.



Relevant Pages

  • Re: Sorting / Grouping and sorting in the stored procedure
    ... Up to this point I have allowed Access to sort the returned record set ... upon Sorting and Grouping criteria. ... My questions is if the retuned record set is presorted, does this help, ... When you use "Sorting and Grouping" feature, ...
    (microsoft.public.access.adp.sqlserver)
  • Re: "Magic" versus "miracle" -- was Re: Evidence for Christianity?
    ... IOW Give the NECESSARY and SUFFICIENT conditions for "miracle" ... some people have believed in some sort of law of "progress" whereby ... and it meets any of three criteria: ... evidence of His special power. ...
    (uk.religion.christian)
  • RE: Sorting and COUNTIF
    ... sheet reference to the criteria in your formula: ... and sort by both columns and it'll still work. ... Sheet 2 has an inventory of four items: ... Brothers posters, and dry-erase markers. ...
    (microsoft.public.excel.misc)
  • VBA - Flexible Sort Macro
    ... In Excel 2003, I know you can have three criteria of sorting (Sort by, ... (representing columns D through I of the sheet) ...
    (microsoft.public.excel.programming)
  • Re: Sorting Records
    ... You can sort the records in the form by setting its OrderBy property, ... If a user enters data in the Number field I would like to sort by number, however, if the user enter criteria in the lock field I would like the records sorted by the lock field. ...
    (microsoft.public.access.formscoding)