On 2020-06-10, chdiza wrote:
> Whatever the sorting order for readdirex() is, it should be possible to use
> Vimscript to return to that sorting order after first sorting by (e.g.,
> filesize or time). That's why I have landed on "the same as >?".
>
> So unless the category expr5 has comparison operators that will follow
> "collation", I do not want "collation order" as the only alternative to the
> current "case sensitive" ordering.
>
> Sketch of example: let foo be the result of calling readdirex(). It's a list
> of
> dicts. It has some sorting order to it, where what's sorted "on" are the
> filename entries in each dict. I might want to use Vimscript to sort foo by
> the
> "time" entry. And then having inspected that, I might want to use Vimscript
> return to sorting foo by filename. This last step ought to put foo back in the
> order it was in when it was first created by readdirex(). Or rather, the
> optional arg for readdirex() that I'm requesting should be able to take a
> value
> that allows for this putting-back.
Exactly! You want a sorting method that sorts a randomly-ordered
list with repeatable, predictable results.
Here's an example. I have a directory that contains three files.
If I read the directory unsorted at all, using either "ls -U" or
"find", I get this list in this order.
readme
README
Readme
If I apply Vim's case-insensitive sort, ":sort i", to that list,
I get the same list, because Vim's :sort is stationary.
readme
README
Readme
Now let me get the files sorted by time by reading the directory
using "ls -t".
README
readme
Readme
If I apply Vim's case-insensitive sort to that list I get the
following.
README
readme
Readme
Note that the list order is unchanged, as expected. Note also that
this order is different from what it was the first time I applied
Vim's case-insensitive sort to the "raw" file list. There is no
way to get back to Vim's case-insensitive sort of the original "raw"
list order using any sorting method other than one specifically
crafted to do that.
If you want all the same letters to sort together, and have
repeatable results so that you can put a list back in that order,
you need to choose a collating order, putting either each of the
lower-case letters before its upper-case equivalent or vice versa.
That is, either
aAbBcC...qQrRsS...
or
AaBbCc...QqRrSs...
> IIUC collation order will not allow this, because IIUC >? and friends don't
> follow collation order.
See above.
> Now one might say "well, just sort foo by >? right after it's created but
> before you display any of its contents." But that puts me right back where I
> was when I opened the GH issue: the time needed to perform that initial
> sorting
> cancels out the time saved by using readdirex() instead of glob() in the first
> place.
I agree that it would be much better to put the sorting in the
C code of the readdirex() function.
> I used to think that Vimscript's glob() put things in my desired order (on
> macOS at least), but I now think I was wrong about that.
I looked briefly at the glob() function but haven't figured it out
yet. I thought it used the shell, but it doesn't.
Regards,
Gary
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20200610194544.GI3695%40phoenix.