Is there a sort option in kentico where you can sort list according to alphabets ?
Like list.split(",").Sort ?
Yes, you can sort macro results. As an example, if you wanted to sort the list of users in your Kentico site by their username, you could use:
GlobalObjects.Users.OrderBy("UserName")
If you want to reverse the order, then you can use:
GlobalObjects.Users.OrderBy("UserName DESC")
If you want to be able to quickly test, you can use the macro console to test your macro output. The console can be found ins the System application under Macros > Console. The horrifyingly fast GIF below shows you where to lookL
"this,is,my,list".Split(",")
in the console, it should work. That though will bring back a string[]
, which I'm not convinces that K# is going to deal with too well. In native C#, you can use "this,is,my,list".Split(',').OrderBy(s => s)
. At the point that you try OrderBy
, it gives you a null
return value though.