add convert and sort function with some tests