Implimented flat sort