'Scenario: the user should be able to sort the list of topics by name or team count
Given I am enrolled in a course with team configuration and topics
When I visit the Teams page
And I browse topics
Then I should see a list of topics for the course
When I choose a sort order
Then I should see the paginated list of topics in that order'

@ddt.data(('name', False), ('team_count', True))
@ddt.unpack
def test_sort_topics(self, sort_order, reverse):

    topics = self.create_topics((TOPICS_PER_PAGE + 1))
    self.set_team_configuration({u'max_team_size': 100, u'topics': topics})
    for (i, topic) in enumerate(random.sample(topics, len(topics))):
        self.create_teams(topic, i)
        topic['team_count'] = i
    self.topics_page.visit()
    self.topics_page.sort_topics_by(sort_order)
    topic_names = self.topics_page.topic_names
    self.assertEqual(len(topic_names), TOPICS_PER_PAGE)
    self.assertEqual(topic_names, [t['name'] for t in sorted(topics, key=(lambda t: t[sort_order]), reverse=reverse)][:TOPICS_PER_PAGE])
