I have two Arrays of different types, 1) say moduleinfo
array which has each element of type
{name :: String, pack :: String }
and 2) String
Array. The simple String
array contains element that is similar to the name
field of moduleinfo
, i.e String
. The simple String
array is already sorted but not the moduleinfo
array.
How do I write a function to sort the moduleinfo
array based on the order of simple String
array. Given that the name
field in moduleinfo
would match with simple String
array elements.
The function shall return a sorted array of moduleinfo
type.
I suggest that you sort
moduleinfo
directly:Here I assume that you have declared a type named
Module
with thename
andpack
elements which you showed in your question.