File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,13 @@ public function collapse(): self
100
100
return new static ($ results );
101
101
}
102
102
103
+ public function ksort (): self
104
+ {
105
+ $ data = $ this ->getArrayCopy ();
106
+ ksort ($ data );
107
+ return new self ($ data );
108
+ }
109
+
103
110
/**
104
111
* Reduce the items to a single value.
105
112
*
Original file line number Diff line number Diff line change @@ -175,4 +175,21 @@ public function testEach(): void
175
175
176
176
$ this ->assertEquals ($ original , $ result );
177
177
}
178
+
179
+ public function testKstort ()
180
+ {
181
+ $ arrayObject = new ArrayObject ([
182
+ 'z ' => 'more test data ' ,
183
+ 'a ' => 'test data ' ,
184
+ 't ' => 'yup moar test data '
185
+ ]);
186
+
187
+ $ expected = [
188
+ 'a ' => 'test data ' ,
189
+ 't ' => 'yup moar test data ' ,
190
+ 'z ' => 'more test data ' ,
191
+ ];
192
+
193
+ $ this ->assertEquals ($ expected , $ arrayObject ->ksort ()->getArrayCopy ());
194
+ }
178
195
}
You can’t perform that action at this time.
0 commit comments