Sort and split