Bubble Sort Multi-dimensional Array

Not that this is any news to anyone - but I found myself onsite at a clients server and simply could not pull this off without the assitance of my good friend Dan Kirkwood at Eagle Innovations and just so I dont forget again here is a quick and easy bubble sort function. This one is really meant for use with a two dimensional array, the first element being numeric, which is what it will sort by.

Use:

sortthis arr

All done!

sub sortthis (byref arr)

dim y, y2, fld1, fld2

fld1 = ""
fld2 = ""

for y = 0 to ubound(arr, 2)
	for y2 = y + 1 to ubound(arr, 2)

		if arr(0, y2) > arr(0, y) then
			fld1 = arr(0, y)
			fld2 = arr(1, y)

			arr(0, y) = arr(0, y2)
			arr(1, y) = arr(1, y2)

			arr(0, y2) = fld1
			arr(1, y2) = fld2
		end if
	next
next

end sub

Comments

Ex ASP 10/23/2007 6:12:27 PM Ughhh, ASP code, yuck!

Leave a Comment

 

 







LATEST POSTS

PostBackUrl Equals Change the Friggin' Form Action . Curse you DBNull and/or Is Nothing! . Career Developers are Shitbags they are. Consolas Makes Me Geek-ier MS Consolas Font Abuse Things I Read Today and You Should Too Whilst searching for solutions I happened upon...

ADS

MOST POPULAR

Multiple IEs in Windows Firefox Vs. The World Who Is Xperya? ActionScript Form Fields Quick Watermark IE 7 beta 2 standalone

IP Address Tool Chicago Web Design Free Text Messaging