add algorithm 4`s sorting code to project