change sorted.subdf.of.state.outcome() to sorted.state.outcome.rank()