I have a list of Chinese strings; for example, like this:
list1 = StringPartition[Import["http://text-share.com/view/c652fa55", "Data"][[-1]], 4]
Now I want to sort it according to Chinese alphabetical order.
There are two equivalent ways, but they differ in efficiency.
The faster way is
AlphabeticSort[new, Entity["Language", "ChineseMandarin"]]; // AbsoluteTiming
(*{0.00261, Null}*)
a much slower way is
SortBy[new, Transliterate]; // AbsoluteTiming
(*{0.465786, Null}*)
However, what if my data is like this:
list2 = Transpose[{list1, Range @ Length @ list1}];
I want to sort this list by the Chinese strings in it. SortBy[list2, Transliterate @ #[[1]] &] is definitely slow. AlphabeticOrder is also slow:
Sort[list2,
AlphabeticOrder[#1[[1]], #2[[1]],
Entity["Language", "ChineseMandarin"]]>=0 &]; // AbsoluteTiming
(*{0.512303, Null}*)
Is it possible to use AlphabeticSort to sort an arbitrary list to get maximum efficiency?
PrintDefinitions[]. See this. – J. M.'s missing motivation Oct 08 '16 at 03:20System`AlphabeticOrderDump? – matheorem Oct 08 '16 at 03:23AlphabeticSort[list, "ChineseMandarin"]first for some shortlistwith Mandarin strings. Then, run the code that I have. I suspect that this is because these internal functions are not loaded untilAlphabeticSort[]is called first. – J. M.'s missing motivation Oct 10 '16 at 05:13