Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
Speller
How To Change The Loader
Snow-Alphamania
Campaign FOR current and future Macromedia Director users
cXtraCD
Export JPEG
Hold for MPEG then go to marker X
Change Cursor
Get Easter Date
myScreen
MediaMacros Xtras Mall
 

 

 

Behavior Bubble Sort for Points and Lists

Added on 6/30/1999

 

Compatibilities:
D6_5 D7 D8 Mac Script

This item has not yet been rated

Author: JamesNewton

Here"s a little handler that will sort points by either their locV (default) or their locH (if you use a non-void second parameter). On my Mac 7600/132, it reverses the order of a 1000 item list in less than 5 ticks, and reverses the order of a 100 item list in less that 1/5th of a tick. The principle can be adapted to sorting a list by any value (for example, the area of a rect). Have fun.

on bubbleSort pointList, horizontally
  -- SORTS VERTICALLY BY DEFAULT
  set horizontally = not voidP (horizontally)
  set pointCount = count (pointList)
  set bubble = TRUE
  repeat while bubble
    set i = pointCount -1
    set bubble = FALSE
    repeat while i
      if horizontally then
        set xLoc1 = the locH of getAt (pointList, i)
        set xLoc2 = the locH of getAt (pointList, i + 1)
      else
        set xLoc1 = the locV of getAt (pointList, i)
        set xLoc2 = the locV of getAt (pointList, i + 1)
      end if
      if xLoc1 > xLoc2 then
        set bubble = TRUE
        set xLoc1 = getAt (pointList, i)
        deleteAt pointList, i
        addAt pointList, i + 1, xLoc1
      end if
      set i = i - 1
    end repeat
  end repeat
  return pointList
end bubbleSort

 


Upload Provided by ABCUpload ASP

Contact

MMI
22 West Court Sq
Suite 2C
Newnan, GA 30263
USA

Fax - (206) 339-5833

Send e-mail