-- I don't remember what the problem was... I think I had to index the LinkedIn -- directory using a tree? -- -- https://www.linkedin.com/directory/people-v/ data User = User { id :: Int , name :: String } data Tree = Node | Tree data Node = Start User | End User (Node (Start (id "V American Clifton")) (End (id "v♡ g♡")) (Tree (Node (Start (id "V American Clifton")) (End (id "VANESSA MITCHELL"))) (Node (Start (id "Vahid Sab")) (End (id "Val Hoskins"))) ) (Node V) 1. First exact matches 2. Results where one of the words is an exact match 3. Results that start with the search string 4. The rest, alphabetically sorted query: "word" correct ordering: [“Word”, “Microsoft Word”, “Wordpress”, “1Password”, “Google AdWords”] "word", "Microsoft Word" for w in words: if exactMatch(w, query): putInFront(w, words) else if contains(w, query): putBehindExactMatches(w, query, words) else if: startsWith(w, query): putBehindContains(w, query, words) else sortAlphabetically(words) f :: String -> [String] -> [String] f "" ls = ls f _ [] = [] f q (x:xs) = if q == x then x:(f xs) else if q `isPrefixOf` x then (f xs):x else if q `isInfixOf` x then placeAfterMatches q (x:xs) else alphabatize((f xs):x) placeAfterMatches :: String -> [String] -> [String] placeAfterMatches _ [] = [] placeAfterMatches q (x:xs) = if q == x then x:(placeAfterMatches q xs) else x:xs placeAfterContains :: String -> [String] - [String] placeAfterContains q (x:xs) = if q `isInfixOf` x then x:(placeAfterContains q xs) else x:xs