;This is a little snippet to use /filter to sort a list by filesize.
;This can help you if you have a list in a dialog, or a window that only has file sizes,
; or in an MDX ListView to list a the files by size when clicking on the size header.
;If you are using MDX, you need to use these lines to check if it's the Size header:
;Just replace "Dialog" with the Dialog name,and "ID" with the list's ID
; var %head = $gettok($did(Dialog,ID,1),3,32) ;This checks what header was clicked (Used only when the event was triggered by clicking on the header)
; tokenize 32 $remove($gettok($gettok($1,%head,9),1,4),$chr(32)) $remove($gettok($gettok($2,%head,9),1,4),$chr(32)) ; This will get the information in Header number %head
; For example, if you know that your Size header is the seconed header, just put 2 instead of %head
; Then to use the alias type this:
; /Filter -acio Dialog ID Dialog ID Sortbysize
; Or if you are using MDX ListView:
; /Filter -arcio 2-9999999 Dialog ID Dialog ID Sortbysize
; The command example will sort the List in the specified Dialog in the same list.
; That's why "Dialog ID" Appears twice: The output ID is the Input ID.
Alias Sortbysize {
if ($2 = n/a) return 1
if (b !isin $2) && (K !isin $2) && (M !isin $2) && (G !isin $2) return 1
if ( ((k !isin $2) && (m !isin $2) && (g !isin $2)) && (B isin $2) ) && ( ((k isin $1) || (m isin $1) || (g isin $1)) && (B !isin $1) ) return 1
if (k isin $1) && (m isin $2) return -1
if (m isin $1) && (G isin $2) return -1
if (m isin $1) && (k isin $2) return 1
if (g isin $1) && ( (m isin $2) || (k isin $2) ) return 1
if ((K isin $1) && (K isin $2)) || ((M isin $1) && (M isin $2)) || ((G isin $1) && (G isin $2)) || $&
( ( ((K !isin $1) && (K !isin $2)) && ((M !isin $1) && (M !isin $2)) && ((G !isin $1) && (G !isin $2)) ) && (b isin $1) && (b isin $2) ) {
tokenize 32 $calc($remove($1,G,K,M,b)) $calc($remove($2,G,K,M,b))
if ($1 !isnum) return 1
return $iif($2 > $1,-1,$iif($1 > $2,1,0))
}
return -1
}