Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorting in advanced way #30

Open
lee1043 opened this issue May 14, 2019 · 3 comments
Open

Sorting in advanced way #30

lee1043 opened this issue May 14, 2019 · 3 comments
Labels
kind/feature Categorizes issue as related to feature request
Milestone

Comments

@lee1043
Copy link

lee1043 commented May 14, 2019

Replacing python's default sorting to more human recognizable way.

import copy
import re

def sort_human(input_list):
    l = copy.copy(input_list)
    convert = lambda text: float(text) if text.isdigit() else text
    alphanum = lambda key: [ convert(c) for c in re.split('([-+]?[0-9]*\.?[0-9]*)', key) ]
    l.sort( key=alphanum )
    return l

Example:

>>> a=['a_1', 'a_11', 'a_2']
>>> sorted(a)
['a_1', 'a_11', 'a_2']
>>> sort_human(a)
['a_1', 'a_2', 'a_11']

Further detail: PCMDI/click#10

@doutriaux1 doutriaux1 self-assigned this May 14, 2019
@doutriaux1 doutriaux1 added this to the Next Release milestone May 14, 2019
@github-actions
Copy link

Marking issue as stale, since there has been no activity in 30 days.

Unless the issue is updated or the 'stale' tag is removed, this issue will be closed in 7 days.

@github-actions github-actions bot added the stale label Aug 27, 2020
@durack1
Copy link
Member

durack1 commented Aug 27, 2020

@lee1043 @pochedls this could be a good candidate for https://github.com/PCMDI/climlib

@github-actions github-actions bot removed the stale label Aug 27, 2020
@github-actions
Copy link

Marking issue as stale, since there has been no activity in 30 days.

Unless the issue is updated or the 'stale' tag is removed, this issue will be closed in 7 days.

@github-actions github-actions bot added the stale label Sep 26, 2020
@jasonb5 jasonb5 added kind/feature Categorizes issue as related to feature request and removed stale enhancement labels Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue as related to feature request
Projects
None yet
Development

No branches or pull requests

4 participants