Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sort elements in local anti-alphabetical

    I am looping through files in a folder


    Code:
    cd "$datain"
    local filelist: dir . files "*.txt"
    foreach file in `filelist' {
    ....
    }
    However, I would like to start with the one that comes alphabetically last. Is there a way to resort the local or loop backwards over the elements?

  • #2
    Code:
    local filelist: list sort filelist
    
    local reversed
    foreach f of local filelist {
        local reversed `f' `reversed'
    }
    
    display `"`reversed'"'
    Now you can loop over `reversed'.

    Added: Probably the first command shown is not needed. I think that filelist is "born" sorted alphabetically when created the way you did it. I'm not certain, though, and it costs very little time to sort it to be sure.

    Comment

    Working...
    X