Re: Sorting char arrays

2012-03-13 Thread Jonathan M Davis
On Tuesday, March 13, 2012 10:13:23 Magnus Lie Hetland wrote: > On 2012-03-12 17:24:56 +, Jonathan M Davis said: > > The problem is that sort requires a random access range, and narrow string > > (string and wstring) aren't, because they're variable length encoded. I'm > > not sure that strings

Re: Sorting char arrays

2012-03-13 Thread Magnus Lie Hetland
On 2012-03-12 17:33:35 +, Ali Çehreli said: You can use isNarrowString to either disallow or provide special implementation for narrow strings (char[] and wchar[]): Ah -- useful, thanks! -- Magnus Lie Hetland http://hetland.org

Re: Sorting char arrays

2012-03-13 Thread Magnus Lie Hetland
On 2012-03-12 17:24:56 +, Jonathan M Davis said: The problem is that sort requires a random access range, and narrow string (string and wstring) aren't, because they're variable length encoded. I'm not sure that strings _can_ be efficiently sorted, because of that, but maybe there's a sortin

Re: Sorting char arrays

2012-03-12 Thread Ali Çehreli
On 03/12/2012 08:06 AM, Magnus Lie Hetland wrote: > On 2012-03-12 13:56:15 +, bearophile said: > >> It's not a bug, char is meant to be a UTF-8. > > Right. > >> Two workarounds: > > Thanks. I'm doing the sorting in a template, so this won't work -- but I > guess I just can't use char as a type

Re: Sorting char arrays

2012-03-12 Thread Jonathan M Davis
On Monday, March 12, 2012 16:04:37 Magnus Lie Hetland wrote: > On 2012-03-12 13:09:18 +, Dmitry Olshansky said: > > Mm it should perform sort on UTF-8 buffer? > > Humm -- dunno ;) The UTF-8-semantics of single characters sort of > slipped my mind :) > > > Tricky thing but worths an enhancemen

Re: Sorting char arrays

2012-03-12 Thread Magnus Lie Hetland
On 2012-03-12 13:56:15 +, bearophile said: It's not a bug, char is meant to be a UTF-8. Right. Two workarounds: Thanks. I'm doing the sorting in a template, so this won't work -- but I guess I just can't use char as a type parameter to my template either, then :) -- Magnus Lie Hetl

Re: Sorting char arrays

2012-03-12 Thread Magnus Lie Hetland
On 2012-03-12 13:09:18 +, Dmitry Olshansky said: Mm it should perform sort on UTF-8 buffer? Humm -- dunno ;) The UTF-8-semantics of single characters sort of slipped my mind :) Tricky thing but worths an enhancement request. I'm just thinking an array of anything that can be compared

Re: Sorting char arrays

2012-03-12 Thread bearophile
Magnus Lie Hetland: The following fails, which I guess is a bug? import std.algorithm; void main() { char[] a = ['a', 'b', 'c']; sort(a); } It's not a bug, char is meant to be a UTF-8. Two workarounds: import std.algorithm; void main() { dchar[] a1 = ['a', 'b', 'c'];

Re: Sorting char arrays

2012-03-12 Thread Dmitry Olshansky
On 12.03.2012 16:51, Magnus Lie Hetland wrote: The following fails, which I guess is a bug? import std.algorithm; void main() { char[] a = ['a', 'b', 'c']; sort(a); } I thought maybe I'd report it -- sort of surprises me that it hasn't been reported before, but I couldn't find it (although I fo

Sorting char arrays

2012-03-12 Thread Magnus Lie Hetland
The following fails, which I guess is a bug? import std.algorithm; void main() { char[] a = ['a', 'b', 'c']; sort(a); } I thought maybe I'd report it -- sort of surprises me that it hasn't been reported before, but I couldn't find it (although I found some similar reports) in t