got the sorting working like I want it to