File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ public function median($key = null)
9595 }
9696
9797 $ values = with (isset ($ key ) ? $ this ->pluck ($ key ) : $ this )
98- ->values ()->sort ();
98+ ->sort ()->values ();
9999
100100 $ middle = (int ) floor ($ count / 2 );
101101
Original file line number Diff line number Diff line change @@ -1310,6 +1310,16 @@ public function testEvenMedianCollection()
13101310 $ this ->assertEquals (1.5 , $ collection ->median ('foo ' ));
13111311 }
13121312
1313+ public function testMedianOutOfOrderCollection ()
1314+ {
1315+ $ collection = new Collection ([
1316+ (object ) ['foo ' => 0 ],
1317+ (object ) ['foo ' => 5 ],
1318+ (object ) ['foo ' => 3 ],
1319+ ]);
1320+ $ this ->assertEquals (3 , $ collection ->median ('foo ' ));
1321+ }
1322+
13131323 public function testMedianOnEmptyCollectionReturnsNull ()
13141324 {
13151325 $ collection = new Collection ();
You can’t perform that action at this time.
0 commit comments