[BUGFIX] Make sorting actually works

See PR #113. Sorting didn't work properly after merge #106, but that's now fixed.