sorting - Sort one list by the order of another list -


I need to sort a list according to the second list, but I do not know how this can be done.

For example: I can have a list a :

  [C, B, G, E]  <[A, B, C, D, E, F, G, B, C, D, E, F, G, ...]   

(Just as an example, These are not real values)

Then, the list should be sorted a list is same as the list b and so on Sorted:

  [A, B, E, G]   

Any help would be greatly appreciated.

If I think, one of the lists lists the sequence relative to all the elements in another list. Ie:

  & gt; Sort with order [5,1,2,3,4] [1,2,3,4,5,5,4,3,2,1] [5,5,1,1,2,2,3, 3, 4, 4]   

This piece of code should work:

  Module sortwhit order where importable data. Map. M Limited as import data. Import Import Data. Ord Sort Wideorder :: Ord A = & gt; [A] - Order list - & gt; [A] - Source list - & gt; [A] Sort with order order = Sort by (compare gore order) where mill orderer = m.fundvith default (-1) k ordermap ordermap = M.fromList (zip order [0 ..])    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -