Sorting and closure

Sorting and closure is added