finnished sort, tested with dict[5] and full test works properly