Begin sort algorithm