sorting - sort an array based on an array of another/different type in haskell or purescript -


i have 2 arrays of different types , 1) moduleinfo array has each element of type

{name :: string, pack :: string }

and 2) string array. simple string array contains element thats similar name filed of moduleinfo type, i.e string. simple string array sorted not moduleinfo array.

now how write function sort moduleinfo array based on order of simple string array. given name field in moduleinfo match simple string array elements.

also function shall return sorted array of moduleinfo type

i suggest sort moduleinfo directly:

sortedmoduleinfo = sortwith (\(module name1 pack1) (module name2 pack2) -> compare name1 name2) moduleinfo 

here assume have declared type named module name , pack elements showed in question.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -