Fixed Horizontal sorting, added unit test