Open
Conversation
As mentioned in Issues 2ndalpha#160 and 2ndalpha#140, the list of hosts is not alphabetized in newer versions of macOS. This change is a feeble attempt by me to sort the `hostsFiles` array as it's populated. It seems to have built successfully on my machine but I'm extremely new to the world of Obj-C development so it would not surprise me in the least if this does something in a bad or easily improved way. That is, I added a way to Sort (`NSSortDescriptor`) and call it immediately after every time we `addObject` to `hostsFiles` during `loadFiles` in LocalHostsController.m. Doing this after every addition seems like it might be a poor choice from a performance perspective. Moreover, it may be wholly unnecessary when used in some environments where this issue doesn't present. I went with it anyway because I didn't know how else to approach this, nor how to conditionally use this logic only when I know it to be necessary.
|
Tested this adjustment with #220 & works – (Local) Hosts files are sorted alphabetically from A-Z 👍 |
This was referenced Mar 12, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


As mentioned in Issues #160 and #140, the list of hosts is not
alphabetized in newer versions of macOS. This change is a feeble
attempt by me to sort the
hostsFilesarray as it's populated.It seems to have built successfully on my machine but I'm
extremely new to the world of Obj-C development so it would not
surprise me in the least if this does something in a bad or
easily improved way.
That is, I added a way to Sort (
NSSortDescriptor) and call itimmediately after every time we
addObjecttohostsFilesduringloadFilesin LocalHostsController.m.Doing this after every addition seems like it might be a poor
choice from a performance perspective. Moreover, it may be
wholly unnecessary when used in some environments where this issue
doesn't present. I went with it anyway because I didn't know how
else to approach this, nor how to conditionally use this logic
only when I know it to be necessary.