implemented sorting for main id table