conversion to sorted sets