sort function second try