This should almost certainly either take `&self`, or use [`self.move_iter()`](http://static.rust-lang.org/doc/master/std/hashmap/struct.HashMap.html#method.move_iter) rather than `.iter()` to allow greater reuse of the already-allocated `~[]`s.

(Also, it looks like `sorted` is almost only ever called on `~[]`s, so it could take that an mutate in-place.)