I'm getting an unexpected result when I sort a list with Excel or with some VBA ( Range.Sort
). It seems that the hyphen is simply ignored when the text is sorted:
List sorted with Excel
align-content
align-items
alignment-baseline << Should be after "align-self"
align-self
animation-delay
The same list sorted with Libre Office
align-content
align-items
align-self
alignment-baseline
animation-delay
The documentation doesn't provide any information on this behavior:
https://msdn.microsoft.com/en-us/library/office/ff840646.aspx
So is there any rule behind this behavior ?
Is there an option to sort the list the same way a human would do (as Libre Office does) ?
Excel ignores hyphens in doing the sort, unless that is the only difference between two words.
One work around is to create a "helper column", replacing the hyphen (code 45) with a dot (code 46). Sort on the helper column
=SUBSTITUTE(A1,"-",".")
I have read someplace that the default sort order has a sequence:
with the first two generally ignored
That being the case, replacing the hyphen with a space might be more logical.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.