split out sort funciton until multiple lines for better stacktrace