Skip to content
This repository was archived by the owner on Mar 18, 2019. It is now read-only.

Commit 1e08ecc

Browse files
committed
Sorted links
1 parent 337a22c commit 1e08ecc

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

coreapi/document.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,19 @@ def _str(node):
2626
def _key_sorting(item):
2727
"""
2828
Document and Object sorting.
29-
Regular attributes sorted alphabetically, then links sorted alphabetically.
29+
Regular attributes sorted alphabetically.
30+
Links are sorted based on their URL and action.
3031
"""
3132
key, value = item
3233
if isinstance(value, Link):
33-
return (1, key)
34+
action_priority = {
35+
'get': 0,
36+
'post': 1,
37+
'put': 2,
38+
'patch': 3,
39+
'delete': 4
40+
}.get(value.action, 5)
41+
return (1, (value.url, action_priority))
3442
return (0, key)
3543

3644

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy