Difference in string sorting Dynamo and Revit

I know I’ve seen something about this before, but here’s the case.
Sorting in a Revit schedule and in Dynamo provides different results. I know there is different kinds of string sorting, but I don’t remember what they’re called, hence google hasn’t helped me either… :wink:

Here’s the same items sorted in Dynamo and Revit:


Hi @jostein_olsen
Maybe the FuzzyDyno package?

Hah, found it myself. :slight_smile: Its called natural sorting:

and it worked as a charm (for reference):

import re

def natural_sort(l): 
    convert = lambda text: int(text) if text.isdigit() else text.lower()
    alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)]
    return sorted(l, key=alphanum_key)