[2693] Added sorted function and changed tests