Skip to content

sort/sort-by does not properly work on maps #708

@ikappaki

Description

@ikappaki

sort and sort-by on a map return the map keys rather than sorted sequences.

to reproduce

  1. Open up a REPL and try to sort a map with some entries
basilisp.user=> (sort {:2 1 :1 3 :3 2})
;; => (:1 :2 :3)
  1. The values returned are the sorted keys rather than a two pair sequences representing the key value pairs.

The same on Clojure returns

user> (sort {:2 1 :1 3 :3 2})
;; => ([:1 3] [:2 1] [:3 2])

sort-by throws an error instead:

basilisp.user=> (sort-by first {:2 1 :1 3 :3 2})
...
  File "C:\src\basilisp\src\basilisp\lang\seq.py", line 255, in sequence
    i = iter(s)
        ^^^^^^^
TypeError: 'Keyword' object is not iterable

while on clojure

user>  (sort-by first {:2 1 :1 3 :3 2})
;; => ([:1 3] [:2 1] [:3 2])

Exploratory PR to follow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions