Alright, so I’m kinda new and this question is what made me make an account on here.
I’ve git a fairly annoying problem and I wish to know of there’s some functionality for this that I dont yet know of.
switchLists :: [[String]] -> [String] -> [[String]]
…
lets call [[string]] mainlist
lets call [string] targetlist
Mainlist contains n smaller lists of equal length with various strings.
Targetlist contains n strings, and each string in Targetlist (all are different from one another) is the first string of some list inside Mainlist. Now the lists in Mainlist are in any order and I need them ordered so that their first strings are in the same order as they are in Targetlist.
It seems I need to go back and fro, check if theres a match but that isnt really great or easy I think.
example:
targetlist = [“dog”, “cat”, “bird”]
mainlist = [ [“cat”, “lion”, “bobcat”, "lynx], [“bird”, “bo”, “crow”, “kolibri”], [“dog”, “husky”, “wolf”, “chichi”] ]
then mainlist must become
: [ [“dog”, “husky”, “wolf”, “chichi”], [“cat”, “lion”, “bobcat”, "lynx], [“bird”, “bo”, “crow”, “kolibri”] ]