ColdFusion Searching and Sorting Algorithms
I used to (back in 2003-2005) post code on this blog very frequently - primarily APIs, implementations of design patterns, and mini-frameworks and sample applications illustrating programming techniques (AOP, OOP, etc.). It's been a while since I've encountered a subject are, technique, or concept that I felt was worth illustrating in code or hasn't already been illustrated in code by someone else... until I picked up that algorithms book for the first time in quite a while. While I read over it again I realized that nowhere that I know of has anyone provided a comprehensive overview/sample of sorting algorithms using CFML. I find that especially surprising given all of the dialogue and emphasis on taking an Object Oriented Programming approach to CF development within the devolpment community. So, I spent many of my New York City subway rides over the past month implementing sorting algorithms in CFML. The result of wihich I'm finally able to share.
I've created implementations of 6 major sorting algorithms in CFML:
- Bubble Sort Algorithm
- Insertion Sort Algorithm
- Merge Sort Algorithm
- Quick Sort Algorithm
- Selection Sort Algorithm
- Shell Sort Algorithm
I've also implemented the Binary Search algorithm (for searching for an object within a sorted array of objects) and the Binary Insert algorithm (for inserting an object directly into its sorted position in a sorted array of objects). In addition to implementing the sorting algorithms, I created a sample of sorting object without algorithms using Query of Queries. Each algorithm is implemented as a CFC, and should work as-is if you drop them into an application. The only code you have to write in order to implement them, is to write a comparitor function (or several if you want to be able to sort on various properties). The comparitor functions always accept 2 arguments and simply return 0 if the two items to compare are the same, 1 if the first argument is greater, or -1 if the second argument is greater. All of the algorithms accept an array of objects (technically you could also pass arrays of other data types if your comparitor functions expect them), and all of them return a sorted array. All of the algorithms support sorting in ascending and descending directions. Sorting objects that are already in memory is often times more efficient than recreating them, and these algorithms will certainly be more efficient than trying to loop/compare using some other linear 'brute force' type of approach.
I'm not going to describe the algorithms themselves here, nor am I going to get into detail about the efficiency of each compared to the others. The sample application times the sorting, inserting, and searching for you and tells you how long each took. The sample application includes an 'about' page in which I describe how each algorithm conceptually works, and I also give some suggestions about their use including recommendations about which algorithms tend to work best in certain scenarios.
You can download all of the code at http://www.horwith.com/downloads/search-sort.zip. I look forward to hearing how people put them to use as well as any other findings with them.

Then I looked up java.util.Collections, and then I realized that there are only binarySearch and sort (that uses MergeSort algorithm) available. They should work with CFML's array (java.util.ArrayList I think?)
Great work. Will any updates be posted here or will you maintain a project at RAIforge?
Thanks!
<a href="http://www.idealhere.com/wholesale-Tattoo_c68">wholesale tattoo</a>
<a href="http://www.idealhere.com/wholesale-Tattoo_c68">cheap tattoo kits</a>
<a href="http://www.idealhere.com/wholesale-Tattoo_c68">tattoo kits for sale</a>
<a href="http://www.idealhere.com/wholesale-Tattoo_c68">tattoo kits sale</a>
<a href="http://www.idealhere.com/wholesale-Tattoo_c68">technical tattoo supply</a>
<a href="http://www.idealhere.com/wholesale-Tattoo_c68">tatoo kits</a>
<a href="http://www.idealhere.com/wholesale-Tattoo_c68">cheap tattoo supplies</a>
<a href="http://www.idealhere.com/wholesale-Tattoo_c68">tattoo equipment supplies</a>
<a href="http://www.idealhere.com/wholesale-Tattoo_c68">international tattoo supply</a>
<a href="http://www.idealhere.com/wholesale-Tattoo_c68">professional tattoo kits</a>
<a href="http://www.idealhere.com/wholesale-Tattoo_c68">worldwide tattoo supply</a>
<a href="http://www.idealhere.com/wholesale-Tattoo_c68">wholesale tattoo supply</a>
<a href="http://www.idealhere.com/wholesale-Tattoo_c68">tattoo equipment supply</a>
<a href="http://www.idealhere.com/wholesale-Tattoo_c68">cheap tattoo equipment</a>
<a href="http://www.idealhere.com/wholesale-Tattoo_c68">tattoo gun kits</a>
<a href="http://www.idealhere.com/wholesale-Tattoo_c68">international tattoo supplies</a>
<a href="http://www.idealhere.com/wholesale-Tattoo_c68">discount tattoo equipment</a>
<a href="http://www.idealhere.com/wholesale-Tattoo_c68">discount tattoo kits</a>
<a href="http://www.idealhere.com/Tattoo-Machines_c238">custom tattoo machine</a>
<a href="http://www.idealhere.com/Tattoo-Machines_c238">tattoo machine kits</a>
<a href="http://www.idealhere.com/Tattoo-Machines_c238">tattoo machine parts</a>
<a href="http://www.idealhere.com/Tattoo-Machines_c238">custom tattoo machines</a>
<a href="http://www.idealhere.com/Tattoo-Machines_c238">buy tattoo machine</a>
<a href="http://www.idealhere.com/Tattoo-Machines_c238">tattoo machine for sale</a>
<a href="http://www.idealhere.com/Tattoo-Machines_c238">cheap tattoo machines</a>
<a href="http://www.idealhere.com/Tattoo-Machines_c238">cheap tattoo machine</a>
<a href="http://www.idealhere.com/Tattoo-Machines_c238">discount tattoo machines</a>
<a href="http://www.idealhere.com/Tattoo-Machines_c238">homemade tattoo machine</a>
<a href="http://www.idealhere.com/Tattoo-Machines_c238">discount tattoo machine</a>
<a href="http://www.idealhere.com/Tattoo-Machines_c238">professional tattoo machines</a>
<a href="http://www.idealhere.com/Tattoo-Machines_c238">tattoo machines for sale</a>
<a href="http://www.idealhere.com/Tattoo-Machines_c238">wholesale Tattoo Machine</a>
<a href="http://www.idealhere.com/Tattoo-Machines_c238">Tattoo Machine wholesale</a>
<a href="http://www.idealhere.com/Tattoo-Machines_c238">Tattoo Machine</a>
<a href="http://www.idealhere.com/wholesale-Needles_c232">cheap tattoo needles</a>
<a href="http://www.idealhere.com/wholesale-Needles_c232">wholesale tattoo needles</a>
<a href="http://www.idealhere.com/wholesale-Needles_c232">discount tattoo needles</a>
<a href="http://www.idealhere.com/Tattoo-Machines_c238">10 Wrap Coils</a>
<a href="http://www.idealhere.com/Tips-and-Nozzles_c239">Tattoo Tubes</a>
<a href="http://www.idealhere.com/Tips-and-Nozzles_c239">Tattoo Tips</a>
<a href="http://www.idealhere.com/Needles_c232">Tattoo Needles</a>
<a href="http://www.idealhere.com/Rotary-Tattoo-Machines_c2...">Rotary Tattoo Machines</a>
<a href="http://www.idealhere.com/wholesale-Tattoo-Machines...">Tattoo Machine Coils</a>
<a href="http://www.idealhere.com/wholesale-Tattoo-Machines...">Tattoo Foot Pedal</a>
<a href="http://www.idealhere.com/wholesale-Power-Supplies-...">Tattoo Power Supply</a>
<a href="http://simulationassuranceauto.org">simulation assurance auto</a>
<a href="http://theaccidentlawyers.org/injury-lawyer/">injury lawyer</a>. It helped me with
ocean of awareness so I really consider you will do much better in the future
http://www.knight4noah.com http://www.fasteveisk.com Eve isk