byteflow has asked for the wisdom of the Perl Monks concerning the following question:
That didn't make any sense. An example will demonstrate:
The hardcoded order of teacher favorites is:
Jim, Tony, Bob, John, Tom, Tim
Now, if the given list is
Bob, Tim, Tony
I want this list to be sorted by the hardcoded order of favorites, and return:
Tony, Bob, Tim.
Another example input list:
Tom, John, Jim
would have the output:
Jim, John, Tom.
Hope that made sense. Basically, sort the given list based on a hardcoded (predefined) order, when the tokens themselves have no alphanumeric significance.
Any ideas would be greatly appreciated. Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sorting based on a specific order
by PeterPeiGuo (Hermit) on Jan 02, 2011 at 06:27 UTC | |
by ikegami (Patriarch) on Jan 02, 2011 at 07:37 UTC | |
|
Re: Sorting based on a specific order
by JavaFan (Canon) on Jan 02, 2011 at 16:04 UTC | |
|
Re: Sorting based on a specific order
by Not_a_Number (Prior) on Jan 02, 2011 at 17:40 UTC | |
|
Re: Sorting based on a specific order
by byteflow (Initiate) on Jan 02, 2011 at 18:41 UTC |