Wrote sorting function