Sort a list of object identifiers: Difference between revisions

No edit summary
Line 617:
</pre>
===Using Piece$() and Stack Sort===
We use a stack (a linked list) to save numbers, and a function to check piece by piece for "largerGrater than" only
 
piece$(a$,".")(i) works from 0
Line 627:
 
<lang M2000 Interpreter>
LTGT=lambda (a$, b$)->{
def i
do {
Line 652:
\\ if peek item i > peek item i+1 then get i+1 to top, and send to i
\\ stack is a linked list, so moving items done with pointers only
if LtGt(stackitem$(i), stackitem$(i+1)) then Shift i+1 : ShiftBack i : addone--
}
} Until Not addone
Line 664:
Using a function which split pieces one time. We have to insert one more item, by append a "." to a$ and b$
<lang M2000 Interpreter>
LTGT=lambda (a$, b$)->{
def i=-1
dim Base 0, a$(), b$()
Anonymous user