Before you start using your list, convert it to an array using ListToArray(), then do an ArraySort() on it. I'd also consider replacing your code with a loop that loops over your list or array and adds the <div> and <img> elements. Then you can accommodate any number of pictures in a more dynamic fashion.
<cfset PicArray = ArraySort( ListToArray( pic ), "text", "asc")> <cfloop array="#PicArray#" index="ThisPic"> <div> <cfoutput> <img width="920" height="300" src="data/images/#ThisPic# /> </cfoutput> </div> </cfloop>
If the picture names have upper and lower case characters, and you want case insensitive sorting, just change "text" to "textnocase" in line 1 above.
Thank you Carl, I think I might have gotten it to work using
getlistat(ListSort(pic, "textnocase"), 1)
Im testing it now, if it doesn't work I will try your method
I am not a backend developer so the least I need to do here the safer I will feel
For some reason I completely forgot about ListSort(). Maybe because there have been issues in the past with handling empty list items (arrays had no problems with empty items).
Anyway, what you have will work. I'd still consider modifying your code to use a loop as it will be more flexible and maintainable. It is not clear from your code how many pictures are actually in the list (always 2, 2 or more, etc.), so a loop will handle all the possibilities without a bunch of repeating code.