Is there any way to retrieve the itemlist sorted by some criteria, without actually applying the sort-order to the list pane?
How do you sort items without sorting them?
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
How do you sort items without sorting them?
Is there any way to retrieve the itemlist sorted by some criteria, without actually applying the sort-order to the list pane?
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
highend
- Posts: 14994
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: How do you sort items without sorting them?
Define criteria 
formatlist() but only for common type(s)
formatlist() but only for common type(s)
One of my scripts helped you out? Please donate via Paypal
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: How do you sort items without sorting them?
criteria are the usual column sort options: date, name, size etc.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
highend
- Posts: 14994
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: How do you sort items without sorting them?
An example for size:
Works the same for date and name can be done by formatlist without any folderreport() / regexreplace()
Code: Select all
$items = folderreport("files:{size RAW}|{fullname}", "r", , , , "<crlf>");
$items = formatlist($items, "n", "<crlf>");
$items = regexreplace($items, "^(\d+\|)(.*)", "$2");
text $items;One of my scripts helped you out? Please donate via Paypal
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: How do you sort items without sorting them?
Brilliant! 
(although a builtin command to return such sorted list would be nice and easier to use)
(although a builtin command to return such sorted list would be nice and easier to use)
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
highend
- Posts: 14994
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: How do you sort items without sorting them?
Build your own and make a sort function out of it 
Like:
Like:
Code: Select all
text sortFiles(, "created", "d");
/*
$path = For which part to report (default = "<curpath>")
$criteria = size (default) | created (date) | modified (date)
$order = "a" (ascending, default), "d" (descending)
$flags = "r" (default) -> recursive or ""
$delim = How should the output be delimited (default = "new line")
*/
function sortFiles($path = "<curpath>", $criteria = "size", $order = "a", $flags = "", $delim = "<crlf>") {
if ($criteria LikeI "size") { $criteria = "size RAW"; }
elseif ($criteria LikeI "created") { $criteria = "created yyyymmddhhnnss"; }
elseif ($criteria LikeI "modified") { $criteria = "modified yyyymmddhhnnss"; }
if ($order LikeI "a") { $order = "n"; }
elseif ($order LikeI "d") { $order = "nr"; }
$items = folderreport("files:{$criteria}|{fullname}", "r", "$path", "$flags", , "<crlf>");
$items = formatlist($items, "$order", "<crlf>");
$items = regexreplace($items, "^(\d+\|)(.*)", "$2");
return regexreplace($items, "\r?\n", $delim);
}One of my scripts helped you out? Please donate via Paypal
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: How do you sort items without sorting them?
That's one way to go about it.
XYScripting gives you a hammer, ... but that doesn't mean a screwdriver becomes useless.
XYScripting gives you a hammer, ... but that doesn't mean a screwdriver becomes useless.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
XYplorer Beta Club