On Wednesday, 13 November 2013 at 11:03:40 UTC, Andrea Fontana wrote:
I'm not sure why sort(vars) doesn't work...

Basically, char[] is a (mutable) string. Since strings in D are treated as UTF, hasLength!(char[]) is actually false. Each "character" can actually be multiple bytes long, so it sort of makes sense. If you were to allow sorting of strings, then characters would be broken apart in the sorting process... so it doesn't do what you would expect it to do in those cases.

So, the way around it is to just treat it as numbers (using std.string.representation, as bearophile pointed out) and sort it that way.

Reply via email to