added sorting option to menu; wrote function for sorting