Fixes sorting bug with immutable lists.