slugger415 has asked for the wisdom of the Perl Monks concerning the following question:
Hello Perl monks, I am in need of some sorting cleverness.
I have a list of long strings that includes URLs and other bits, e.g.
http://myurl.com/search/stringA?SomeMoreStuffA http://myurlA.com/search/stringB?SomeMoreStuffB http://myurlB.com/search/stringC?SomeMoreStuffX http://myurlC.com/search/stringA?SomeMoreStuffXYZ http://myurl.com/search/stringZ?SomeMoreStuffZZZ
I want to sort on just the strings between /search/ and the ? character, e.g.
$URL =~/search/(.+)\? my($searchString) = $1;
(Note that rows 1 and 4 above will have identical $searchString values.)
But I also want to keep a reference to the full original URL string and anything else in the string.
I can obviously create an array with the $searchString values and sort that, but how do I map them to the original full string? I can't use a hash, since there are often duplicates (e.g. rows 1 and 4 above, both 'stringA').
Any thoughts? Thanks much as always.
Scott
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sorting on identical values
by tybalt89 (Monsignor) on Aug 08, 2019 at 17:26 UTC | |
|
Re: Sorting on identical values
by holli (Abbot) on Aug 08, 2019 at 17:26 UTC | |
|
Re: Sorting on identical values
by BillKSmith (Monsignor) on Aug 08, 2019 at 18:15 UTC | |
|
Re: Sorting on identical values (updated)
by AnomalousMonk (Archbishop) on Aug 08, 2019 at 20:31 UTC | |
|
Re: Sorting on identical values
by slugger415 (Monk) on Aug 08, 2019 at 22:41 UTC | |
by AnomalousMonk (Archbishop) on Aug 09, 2019 at 00:12 UTC | |
by Anonymous Monk on Aug 14, 2019 at 01:19 UTC | |
by AnomalousMonk (Archbishop) on Aug 21, 2019 at 20:16 UTC | |
by BillKSmith (Monsignor) on Aug 09, 2019 at 15:52 UTC |