Tinderbox Forum

Sort for numbers less than 10

I’m sorting a list of numbers with the following action code:

^value((collect_if(descendants(this),$Prototype=="Data Extract",$PID)).unique.sort.format("<ol>","<li>","</li>","</ol>"))^

And getting the following result:

The attribute $PID type is number. I’ve tried to change that to 05 but it doesn’t take.



There’s a specific sort for number attributes .nsort(). https://acrobatfaq.com/atbref8/index/ActionsRules/Operators/FullOperatorList/ListnsortAttribute.html

Does that work?


Sure does! Didn’t know about .nsort(). Thank you, @brookter!

You’re welcome!

I was going to suggest that I think you can pad the single numbers for right alignment but it looks like there are a few wrinkles to that: https://acrobatfaq.com/atbref8/index/ActionsRules/Operators/FullOperatorList/NumberformatdecimalsNwid.html

Interesting! Thanks for the tip.

@brookteris correct on .nsort for sorting numbers (i.e. Number-type data). The number.format()approach, linked to above results in a _String_. If you were making zero-left-padded number strings, then.sort` would work.

Why this variation in the way things sort? See more on Lexical vs. Numeric sorting