restore _sort functionality; add few tests on it;