Remove double-sorting of elements