diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 787f856..c603210 100644
a
|
b
|
class ModelAdmin(BaseModelAdmin):
|
576 | 576 | # get_action might have returned None, so filter any of those out. |
577 | 577 | actions = filter(None, actions) |
578 | 578 | |
579 | | # Convert the actions into a SortedDict keyed by name |
580 | | # and sorted by description. |
581 | | actions.sort(key=lambda k: k[2].lower()) |
| 579 | # Convert the actions into a SortedDict keyed by name. |
582 | 580 | actions = SortedDict([ |
583 | 581 | (name, (func, name, desc)) |
584 | 582 | for func, name, desc in actions |
diff --git a/tests/regressiontests/admin_views/models.py b/tests/regressiontests/admin_views/models.py
index 6e34ee1..854fb60 100644
a
|
b
|
def external_mail(modeladmin, request, selected):
|
341 | 341 | 'from@example.com', |
342 | 342 | ['to@example.com'] |
343 | 343 | ).send() |
| 344 | external_mail.short_description = 'External mail (Another awesome action)' |
344 | 345 | |
345 | 346 | def redirect_to(modeladmin, request, selected): |
346 | 347 | from django.http import HttpResponseRedirect |
347 | 348 | return HttpResponseRedirect('/some-where-else/') |
| 349 | redirect_to.short_description = 'Redirect to (Awesome action)' |
348 | 350 | |
349 | 351 | class ExternalSubscriberAdmin(admin.ModelAdmin): |
350 | | actions = [external_mail, redirect_to] |
| 352 | actions = [redirect_to, external_mail] |
351 | 353 | |
352 | 354 | class Media(models.Model): |
353 | 355 | name = models.CharField(max_length=60) |
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
index 0537160..947732f 100644
a
|
b
|
class AdminActionsTest(TestCase):
|
1971 | 1971 | response = self.client.post(url, action_data) |
1972 | 1972 | self.assertRedirects(response, url) |
1973 | 1973 | |
| 1974 | def test_actions_ordering(self): |
| 1975 | """ |
| 1976 | Ensure that actions are ordered as expected. |
| 1977 | Refs #. |
| 1978 | """ |
| 1979 | response = self.client.get('/test_admin/admin/admin_views/externalsubscriber/') |
| 1980 | self.assertTrue('''<label>Action: <select name="action"> |
| 1981 | <option value="" selected="selected">---------</option> |
| 1982 | <option value="delete_selected">Delete selected external subscribers</option> |
| 1983 | <option value="redirect_to">Redirect to (Awesome action)</option> |
| 1984 | <option value="external_mail">External mail (Another awesome action)</option> |
| 1985 | </select>'''in response.content, |
| 1986 | ) |
| 1987 | |
1974 | 1988 | def test_model_without_action(self): |
1975 | 1989 | "Tests a ModelAdmin without any action" |
1976 | 1990 | response = self.client.get('/test_admin/admin/admin_views/oldsubscriber/') |