set myColors to current application's class "NSMutableArray"'s arrayWithObjects_("red", "green", "blue", "yellow", missing value)
set sortedArray to myColors's sortedArrayUsingSelector_("localizedCaseInsensitiveCompare:")
Thank you for the answer. I have another question in that what if I want to represent the colors as a variable like shown below. I am not getting a sorted results. Could you help please.
set myColors to {“red”, “green”, “blue”, “yellow”}
set theArray to current application’s class “NSMutableArray”'s arrayWithObjects_(myColors, missing value)
set sortedArray to theArray’s sortedArrayUsingSelector_(“localizedCaseInsensitiveCompare:”)
set myColors to {"red", "green", "blue", "yellow"}
set theArray to current application's class "NSMutableArray"'s arrayWithArray_(myColors)
set sortedArray to theArray's sortedArrayUsingSelector_("localizedCaseInsensitiveCompare:")
log sortedArray
the type of the parameter of sortedArrayUsingSelector is a selector (a method), the colon indicates that the method takes one parameter.
The ObjC method is