Russ has asked for the wisdom of the Perl Monks concerning the following question: ⭐ (sorting)
I need to sort a list of strings which are network line speeds,
like: "115kbps", "2Mbps", "10Mbps", "T1 LINE", ...
If I do the standard (ASCIIbetical) sort, "10Mbps" would come before "115kbps", and "115kbps" would come before "2Mbps", which is clearly not the result I want.
So I need some trick to make a "priority hash" or array where I'd put the proper order of sort.
I understand how to make comparisons in the subroutine:
return -1; # moves the item lower return +1; # goes above the previous one return 0; # equals
Originally posted as a Categorized Question.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How do I write my own sorting routine?⭐
by jarich (Curate) on Dec 22, 2003 at 05:57 UTC | |
by Roger (Parson) on Dec 22, 2003 at 12:44 UTC | |
Re: How do I write my own sorting routine?⭐
by nardo (Friar) on Jul 05, 2000 at 22:38 UTC | |
Re: How do I write my own sorting routine?
by gam3 (Curate) on Mar 26, 2005 at 01:36 UTC | |
by tlm (Prior) on Mar 26, 2005 at 03:50 UTC | |
Re: How do I write my own sorting routine?
by poolpi (Hermit) on Jan 27, 2009 at 15:35 UTC | |
Re: How do I write my own sorting routine?
by St{)ìÑ (Initiate) on Oct 19, 2002 at 18:49 UTC |
Back to
Seekers of Perl Wisdom