[erlang-questions] Sorting of lists

t ty tty.erlang@REDACTED
Thu Apr 19 20:30:09 CEST 2007


Well it looks like MyList already encodes the position in Names. To
sort MyList use lists:keysort/2.

t

On 4/19/07, Fredrik Hoback <fredrik.hoback@REDACTED> wrote:
> Hi, I've this problem:
>
> If you have a list containing elements like this:
> Names = [adam, billy, ceasar, david]
>
> and then I have another list:
>
> MyList = [ {3, ceasar}, {1, adam}, {4, david}, {2, billy}]
>
> then I would like to order MyList according to Names, so MyList would
> look like this:
>
> [{1, adam}, {2, billy}, {3, ceasar},  {4, david}].
>
> How would a function look like to get MyList sorted according to Names ?
> ---------------------------------
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list