On 03/09/17 10:45, Cliff Stanford wrote:

OK, presumably I'd need to do this in each map function? Do I need to copy and paste the code to each function or is there any way to use subroutines across map function?

Actually, I realised there is a fairly simple way to do this in three extra lines of (coffeescript) code:

alphabet =  "ABDEFGHIJKLMNOPRSŠZŽTUVÕÄÖÜ"
collation = "ABCDEFGHIJKLMNOPQRSTUVWXYZŽ"
sort = (collation[alphabet.indexOf char.toUpperCase()] ? char for char in word.split '').join ''emit [sort, word]

Emitting the word too keeps the cases sorted.

Of course, this will break if I have any words with the "foreign" letters in (C Q W X Y) but the concept is easy to extend.

Thanks all for your help.

Regards
Cliff.

--
Cliff Stanford
London:    +44 20 0222 1666               Swansea: +44 1792 469666
Spain:     +34  603 777 666               Estonia: +372  5308 9666
UK Mobile: +44 7973 616 666

Reply via email to