This is a solution not changing original list:

import Html exposing (text)
import String exposing (toUpper)

main =
  text (toString sortedList)
  
sortedList : List String
sortedList =
  [ "c", "B" , "a" ] |> List.sortWith compareIgnoreCase
  
compareIgnoreCase : String -> String -> Order
compareIgnoreCase a b =
  case compare (toUpper a) (toUpper b) of
    LT -> LT
    EQ -> EQ
    GT -> GT

Efficiency can be improved by keeping a cache of already upper cased 
letters.


On Friday, September 9, 2016 at 5:45:01 PM UTC+2, Rudolf Bargholz wrote:
>
> Hi,
>
> Failing here dismally, so I hope someone here is kind enough to help out.
>
> *Problem*: I have a list of strings and want to sort the list independant 
> of the case of the chars in the string
>
> What I have so far:
>
> > import List
> > import String
> > unorderedList = [ "c", "B" , "a"]
> ["c","B","a"] : List String
> > orderedList = List.sort unorderedList
> ["B","a","c"] : List String
> > orderedList2 = unorderedList |> List.map String.toUpper |> List.sort
> ["A","B","C"] : List String
>
>
> What I am trying to acheive is the following result:
>
> ["a","B","c"] : List String
>
> I must be overlooking something easy. 
>
> Could anyone point me in the right direction how I can accomplish this?
> Is there any resource that has numerous Elm examples on how to use 
> *List.sort*, *List.sortBy* and *List.sortWith*?
>
> Regards
>
> Rudolf Bargholz
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to