in reply to Re^2: Regex Substring SORT Conundrum
in thread Regex Substring SORT Conundrum

It's definitely worth the effort. Let me see if I can break down the map I gave (and maybe clean it up a bit). Starting from
map { /^(.*)(?>(?:\s.{1,5}(:\d+)*.*))/; [$_, $sortdata{$1}, $2, $3] }
you should read it like
map { my ($book, $chapter, $verse) = /^(.*)(?>(?:\s.{1,5}(:\d+)*.*))/; + [$_, $sortdata{$book}, $chapter, $verse] }
(I'm taking for granted that your regex works like that) For each element of your list, it
  1. assigns the element to $_
  2. applies the regex and assigns the captures to ($book, $chapter, $verse)
  3. creates an anonymous array [ ] with the original element at index 0 and the other 3 which you'll use in the sort
  4. passes it on to the next process
so from your first list, you get a list of anonymous arrays for your sort which you can reference using $_->2 for the chapter, etc. Also remember that $a->[1] <=> $b->[1] sorts numerically while $a->[1] cmp $b->[1] sorts alphabetically. The map on the other side of the sort takes the list of sorted anonymous arrays and reduces it to the original elements, now sorted.

A better explanation of the Transform is in the Modern Perl book

Sometimes I can think of 6 impossible LDAP attributes before breakfast.