This used to print true-false, but in DMD 2.062alpha prints true-true on Windows: import std.stdio, std.algorithm; void main() { auto x = "abcd"; writeln(isSorted(x)); auto y = "acbd"; writeln(isSorted(y)); } Maybe this line: https://github.com/D-Programming-Language/phobos/blob/master/std/algorithm.d#L9237 for (; !ahead.empty; ahead.popFront(), ++i) Should be: for (; !ahead.empty; ahead.popFront(), r.popFront(), ++i)
A comment from Brad Anderson: > Looks like line 9221 is essentially the same code so you may want > to change that line too.
This used to work not too much time ago.
https://github.com/D-Programming-Language/phobos/pull/1136 Thanks for your fix Bearophile.
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/98cb833137c1c7cb9a51e7acb3cdf43332e0c7ac Fixes Issue 9457 - isSorted(string) does not work. https://github.com/D-Programming-Language/phobos/commit/8bf6997acfdbe81442e4c3e4c3500b9197ffaaca Merge pull request #1136 from AndrejMitrovic/Fix9457 Issue 9457 - isSorted(string) does not work.
Commit pushed to staging at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/e652b208dce5b36ab4c4d6b38fc537edf7013148 Fixes Issue 9457 - isSorted(string) does not work.