?sort_by() takes a string or array of strings as a...
# suitescript
t
?sort_by() takes a string or array of strings as arg to indicate which field/fields to sort by, so I've tried type-casting to an integer where i'm passing it to the sort property but it fails to render the list, ex:
Copy code
<#list JSON.items?sort_by(palletnum?number) as item>
s
Can you sort the items yourself (coercing to numbers in the meantime)? If you're building the JSON.items data yourself, can you sort it (in code) before passing to the template renderer?
t
Hmm, this may work actually. I dismissed the idea right away since I'm building the JSON object from a sublist, and sorting sublists is usually a cheap ticket to insanity, but there's no reason i can't sort the JSON object after sourcing
Thanks!
s
right, sounds like an easy job for lodash.sortBy() if you can do it in JS land rather than Freemarker land.