all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,26 @@
|
|||
FUNCTION Sorter(p1 AS STRING, p2 AS STRING) AS LONG
|
||||
'if p1 should be first, returns -1
|
||||
'if p2 should be first, returns 1
|
||||
' if they're equal, returns 0
|
||||
IF LEN(p1) > LEN(p2) THEN
|
||||
FUNCTION = -1
|
||||
ELSEIF LEN(p2) > LEN(p1) THEN
|
||||
FUNCTION = 1
|
||||
ELSEIF UCASE$(p1) > UCASE$(p2) THEN
|
||||
'if we get here, they're of equal length,
|
||||
'so now we're doing a "normal" string comparison
|
||||
FUNCTION = -1
|
||||
ELSEIF UCASE$(p2) > UCASE$(p1) THEN
|
||||
FUNCTION = 1
|
||||
ELSE
|
||||
FUNCTION = 0
|
||||
END IF
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION PBMAIN()
|
||||
DIM x(7) AS STRING
|
||||
ARRAY ASSIGN x() = "Here", "are", "some", "sample", "strings", "to", "be", "sorted"
|
||||
|
||||
'pb's built-in sorting; "USING" tells it to use our custom comparator
|
||||
ARRAY SORT x(), USING Sorter()
|
||||
END FUNCTION
|
||||
Loading…
Add table
Add a link
Reference in a new issue