kicad/old/scripts/KiBoM/bomlib/sort.py

12 lines
263 B
Python
Raw Normal View History

2020-02-04 17:33:02 -07:00
# -*- coding: utf-8 -*-
import re
def natural_sort(string):
"""
Natural sorting function which sorts by numerical value of a string,
rather than raw ASCII value.
"""
return [int(s) if s.isdigit() else s for s in re.split(r'(\d+)', string)]