Day 024: LCASE$
#11
(12-04-2022, 01:48 PM)SMcNeill Wrote: A better solution, in a case like this, is to minimize the usage of that slow processing string command, as much as possible.
Code: (Select All)
DIM tempArray(UBOUND(Array)) AS STRING
FOR i = 0 TO UBOUND(Array)
    tempArray(i) = LCASE$(Array(i))
NEXT

 FOR x = 0 TO UBOUND(tempArray)
    FOR y = 0 TO UBOUND(tempArray)
        IF tempArray(x) < tempArray(y) THEN SWAP tempArray(x), tempArray(y)
    NEXT
NEXT

FOR i = 0 TO UBOUND(Array)
    Array(i) = tempArray(i)
NEXT

Surely this is a good opportunity to use _StriCmp to keep the code neat while still achieving good performance?

Code: (Select All)
For x = 0 To UBound(Array)
    For y = 0 To UBound(Array)
        If _StriCmp(Array(x), Array(y)) = -1 Then Swap Array(x), Array(y)
    Next
Next
Reply


Messages In This Thread
Day 024: LCASE$ - by Pete - 12-04-2022, 05:17 AM
RE: Day 024: LCASE$ - by mnrvovrfc - 12-04-2022, 12:01 PM
RE: Day 024: LCASE$ - by luke - 12-04-2022, 01:25 PM
RE: Day 024: LCASE$ - by SMcNeill - 12-04-2022, 01:48 PM
RE: Day 024: LCASE$ - by mnrvovrfc - 12-04-2022, 05:57 PM
RE: Day 024: LCASE$ - by SMcNeill - 12-04-2022, 10:47 PM
RE: Day 024: LCASE$ - by Pete - 12-04-2022, 04:10 PM
RE: Day 024: LCASE$ - by Pete - 12-04-2022, 06:47 PM
RE: Day 024: LCASE$ - by SMcNeill - 12-04-2022, 11:16 PM
RE: Day 024: LCASE$ - by Pete - 12-05-2022, 12:59 AM
RE: Day 024: LCASE$ - by luke - 12-05-2022, 07:30 AM
RE: Day 024: LCASE$ - by mnrvovrfc - 12-05-2022, 08:24 AM
RE: Day 024: LCASE$ - by Pete - 12-05-2022, 10:38 AM



Users browsing this thread: 1 Guest(s)