This content has been marked as final. Show 3 replies
one could use listtoarray() and arraysort() functions...
but if you want to sort by both first name and last name, then you are
better off populating a temporary query with the name and then ordering it
Maybe I should ask in a slightly different way
if I have a string of names:
Damian Dadswell, Joe Bloggs
how can I / am I able to order those alphabetically?
your "string of names" is a comma-delimited list. use <cfset myarray =
listtoarray(yourstringofname, ",") to convert it to an array. then you
can do <cfset myarray = arraysort(myarray)>
but be aware of any names that contain a ",", like Joe Smith, Jr. - this
name will be considered to names in a comma-delimited list.
once again, repeating myself, if you want to be able to sort your names
by both first name and last name, then you should populate a temp query
with the names and then order it and cfoutput it:
define a temp query with 2 columns (firstname, lastname);
loop through your list of names, adding a new temp query row and
populating it with first name and last name with each loop;
after the loop run a QoQ on the temp q to order it by firstname or lastname;
cfoutput the QoQ