added custom sort function for ArrayList