digitalmars.D.learn - aa.byKeyValue().sort!"a.key < b.key"
- Nicholas Wilson (22/22) Jun 27 2015 How do I iterate through an AA sorted by key?
- H. S. Teoh via Digitalmars-d-learn (7/10) Jun 27 2015 Because it is a range, not an array.
- Nicholas Wilson (3/12) Jun 27 2015 Derp.
How do I iterate through an AA sorted by key?
I am unable to .dup the aa.byKeyValue().
I have tried both
foreach(e; aa.byKeyValue().sort!"a.key < b.key")
{
//... use e. key && e.value
}
and
foreach(k,v; aa.byKeyValue().sort!"a.key < b.key")
{
}
i get :
template std.algorithm.sorting.sort cannot deduce function from
argument types !("a.key < b.key")(Result), candidates are:
std/algorithm/sorting.d(875):
std.algorithm.sorting.sort(alias less = "a < b", SwapStrategy ss
= SwapStrategy.unstable, Range)(Range r) if ((ss ==
SwapStrategy.unstable && (hasSwappableElements!Range ||
hasAssignableElements!Range) || ss != SwapStrategy.unstable &&
hasAssignableElements!Range) && isRandomAccessRange!Range &&
hasSlicing!Range && hasLength!Range)
any clues?
Jun 27 2015
On Sat, Jun 27, 2015 at 12:22:06PM +0000, Nicholas Wilson via Digitalmars-d-learn wrote:How do I iterate through an AA sorted by key? I am unable to .dup the aa.byKeyValue().Because it is a range, not an array. To turn it into an array, write: aa.byKeyValue().array.sort!"a.key < b.key" T -- Three out of two people have difficulties with fractions. -- Dirk Eddelbuettel
Jun 27 2015
On Saturday, 27 June 2015 at 12:27:59 UTC, H. S. Teoh wrote:On Sat, Jun 27, 2015 at 12:22:06PM +0000, Nicholas Wilson via Digitalmars-d-learn wrote:Derp. Thankyou!How do I iterate through an AA sorted by key? I am unable to .dup the aa.byKeyValue().Because it is a range, not an array. To turn it into an array, write: aa.byKeyValue().array.sort!"a.key < b.key" T
Jun 27 2015








"Nicholas Wilson" <iamthewilsonator hotmail.com>