Erlang - sort



Sorts a list of elements.

Syntax

sort(lst)

Parameters

  • Lst − The list of elements which needs to be sorted.

Return Value

Returns a sorted list of elements.

For example

-module(helloworld). 
-import(lists,[sort/1]). 
-export([start/0]). 

start() -> 
   Lst1=[5,6,4], 
   io:fwrite("~p~n",[sort(Lst1)]).

Output

When we run the above program, we will get the following result.

[4,5,6]
erlang_lists.htm
Advertisements