Designed for sorting SGPs according to various criteria, try to improve performance