We don't bite newbies here... much | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Hi,
What about inverting the search? You already know the order of the characters. Match them as many times as possible against the input string as a regex with each character as an alternative (ie input "QRKPNB" becomes /Q|R|K|P|N|B/ )? These couple of lines generate the regex based on the input and match the sorted list against it. The joined matches become the (sorted) output string:
Hope it might be of use or interest to your application RubenIn reply to Re: Sort list by position of items in another list
by drclaw
|
|