add sorting & unit tests