Fixes sorting behavior to match C++.