Re-added Sort function