changed treeset to slightly more generic sortedset