Fix reverse sorts to keep folders first
This commit is contained in:
parent
2ea56fd045
commit
9b5c9553f0
@ -303,7 +303,7 @@ if {$parent ne ""} {
|
||||
"
|
||||
}
|
||||
|
||||
proc s_file_stat {a b attr} {
|
||||
proc s_file_stat {a b attr {rev 0}} {
|
||||
global dir
|
||||
|
||||
set a "$dir/$a"
|
||||
@ -325,8 +325,8 @@ proc s_file_stat {a b attr} {
|
||||
if {[catch {file stat $b l}]} { return 0}
|
||||
set bt $l($attr)
|
||||
|
||||
if {$at < $bt} { return -1 }
|
||||
if {$at > $bt} { return 1 }
|
||||
if {$at < $bt} { return [expr {$rev ? 1 : -1}] }
|
||||
if {$at > $bt} { return [expr {$rev ? -1 : 1}] }
|
||||
return 0
|
||||
}
|
||||
|
||||
@ -334,10 +334,18 @@ proc s_time {a b} {
|
||||
tailcall s_file_stat $a $b mtime
|
||||
}
|
||||
|
||||
proc s_time_r {a b} {
|
||||
tailcall s_file_stat $a $b mtime 1
|
||||
}
|
||||
|
||||
proc s_size {a b} {
|
||||
tailcall s_file_stat $a $b size
|
||||
}
|
||||
|
||||
proc s_size_r {a b} {
|
||||
tailcall s_file_stat $a $b size 1
|
||||
}
|
||||
|
||||
proc s_ext {a b} {
|
||||
set at [file extension $a]
|
||||
set bt [file extension $b]
|
||||
@ -350,11 +358,11 @@ proc s_ext {a b} {
|
||||
|
||||
set files [readdir -nocomplain $dir]
|
||||
switch $order {
|
||||
5 { set files [lsort -command s_ext $files] }
|
||||
1 { set files [lsort -command s_time $files] }
|
||||
2 { set files [lreverse [lsort -command s_time $files]] }
|
||||
2 { set files [lsort -command s_time_r $files] }
|
||||
3 { set files [lsort -command s_size $files] }
|
||||
4 { set files [lreverse [lsort -command s_size $files]] }
|
||||
4 { set files [lsort -command s_size_r $files] }
|
||||
5 { set files [lsort -command s_ext $files] }
|
||||
default { set files [lsort -nocase $files] }
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user