Wrap sort order. Fixes #450

Fixed as described in #450