home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Documentation / snippets / listsort.cfm < prev    next >
Encoding:
Text File  |  1999-04-12  |  1.4 KB  |  58 lines

  1. <!--- This example shows ListSort--->
  2. <HTML>
  3. <HEAD>
  4. <TITLE>ListSort Example</TITLE>
  5. </HEAD>
  6.  
  7. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  8. <BODY  bgcolor="#FFFFD5">
  9.  
  10. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  11. <BODY  bgcolor="#FFFFD5">
  12. <H3>ListSort Example</H3>
  13.  
  14. <!--- Find a list of users who wrote messages --->
  15. <CFQUERY NAME="GetMessageUser" DATASOURCE="cfsnippets">
  16. SELECT    Username, Subject, Posted
  17. FROM    Messages
  18. </CFQUERY>
  19.  
  20. <CFSET myList = ValueList(GetMessageUser.UserName)>
  21. <P>Here is the unsorted list. </P>
  22.  
  23. <CFOUTPUT>
  24. #myList#
  25. </CFOUTPUT>
  26. <P>Here is the list sorted alphabetically:</P>
  27. <CFSET sortedList = ListSort(myList, "Text")>
  28. <CFOUTPUT>
  29. #sortedList#
  30. </CFOUTPUT>
  31.  
  32. <P>Here is a numeric list that is to be sorted in descending order.</P>
  33. <CFSET sortedNums = ListSort("12,23,107,19,1,65","Numeric", "Desc")>
  34. <CFOUTPUT>
  35. #sortedNums#
  36. </CFOUTPUT>
  37.  
  38. <P>Here is a list that must be sorted numerically, since it contains both negative and positive numbers, as well as decimal numbers. </P>
  39.  
  40. <CFSET sortedNums2 = ListSort("23.75;-34,471:100,-9745","Numeric", "ASC", ";,:")>
  41.  
  42. <CFOUTPUT>
  43. #sortedNums2#
  44. </CFOUTPUT>
  45.  
  46. <P>Here is a list that is to be sorted alphabetically without consideration of case.</P>
  47.  
  48. <CFSET sortedMix = ListSort("hello;123,HELLO,hello:jeans,-345,887;ColdFusion:coldfusion", "TextNoCase", "ASC", ";,:")>
  49.  
  50. <CFOUTPUT>
  51. #sortedMix#
  52. </CFOUTPUT>
  53.  
  54. </BODY>
  55. </HTML>       
  56.  
  57.  
  58.