sorting added. Tested for mac and not for linux yet