-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add optionnable sorting capability #2
Conversation
# Conflicts: # test/readify.js
done ! |
Thank you, code a little bit messy but idea understandable :). I need to think about it a little bit. |
res = -res; | ||
} | ||
return res; | ||
}, array); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think sort-by can be used for sorting. It can simplify code a little bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not but no commit since 1 year ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sort by seams very straightforward. We could fork it and write a backport with 'classic' attribute access.
Yes it's messy ... |
We could add a formatting dedicated function ( in the squad stack line 202 ) to avoid having the raw attribute condition and manipulate only raw items internally. |
1 similar comment
1 similar comment
const cmpCallbacks = { | ||
'numeric': (a, b) => (+a - +b), | ||
'local_string': (a, b) => a.localeCompare(b.attr), | ||
'default': (a, b) => (a > b ? 1 : -1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What difference between default
and numeric
sorting?
What purpose of localeCompare
? As I understand from mdn without locales
argument it will work in the same way as default
sorting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not much, it enforces the numeric cast with the dir
value. But since I've switched formatting it maybe useless now.
localCompare is for accents. I'm french and I deal with accentuated letters like é è ë ê. Those letters have the same rank than e. Standard comparison put them after z.
http://www.jstips.co/en/sorting-strings-with-accented-characters/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
localCompare is for accents. I'm french and I deal with accentuated letters like é è ë ê.
That is interesting. Did not know about it.
Can you show me please how ls -lha
sorts accents?
OK, so |
# Conflicts: # .gitignore # lib/readify.js # test/readify.js
1 similar comment
1 similar comment
# Conflicts: # lib/readify.js
1 similar comment
cfa9e7e
to
5fd274c
Compare
It is a good idea. Could you please squash your commits to one, remove |
so I have to sort in the readdir file ? |
We can start from adding sorting by size, name, and modification time with order support. And drop support of owner sorting. We can add it later. |
OK you've just move sorting from readdir to readify :p because as it, I was confused. |
hey I gave it a try ;p
Ok it took me 3 hours to write 30 lines ;p It's my first Node JS stuff ever (like a virgin)...
I had to introduce a technical
_raw
raw
attribute to the file structure to sort formatted data...I not very pleased with this double data structure but it works...
I've added some basic test and fix errors induced by the new attribute...
give me some feedback !!