changed sort function as safari doesnt like it