Change order to sortperm and other changes to track Julia changes.