add functional sorting