ScriptSpot

Forum topic · General Scripting

Sorting Array with non string items

By jtwographics · 2016-07-08

Description

I have two questions that are trying to get to the same place

I am creating an array of all modifiers,

modArr = modifier.classes

Is there a way to sort this array into alphabetical order since the items are not strings?

Or is there a way to force "modifier.classes" to return the list in alphabetical order?

Thanks!

Comments (1)

barigazy · 2016-07-14

I will love to see if someone have the answer why this not works


fn sortAlphabetical class = 
(
	name = with PrintAllElements on class as string
	name = filterstring stlclass "#(), "
	name = sort name 
	for c in class collect class[(finditem name (c as string))]
)
sortAlphabetical modifier.classes

Anyway this works but we need to use "EXECUTE"

:(


fn sortAlphabetical class =
(
name = with PrintAllElements on class as string
name = filterstring stlclass "#(), "
name = sort name
for m in name collect execute m
)
sortAlphabetical modifier.classes