added sort tier function