More efficient Bubble Sort
Category:C#, VB.NET, ASP.NET
Version Compatibility: Visual Basic 6
This is Joel's Bubble Sort Function, revised only slightly for efficiency. The first pass through the loop places the smallest value in position (lStart). Pass 2 places the next smallest (or equal) value in position (lStart+1). The addition of counter "lPass" eliminates wasted iterations of the For - Next loop.
Instructions: Copy the declarations and code below and paste directly into your VB project.