Sortieren Sie ein 2D -Array nach den Float -Werten einer Spalte [Duplikat]Php

PHP-Programmierer chatten hier
Anonymous
 Sortieren Sie ein 2D -Array nach den Float -Werten einer Spalte [Duplikat]

Post by Anonymous »

Ich habe das folgende Array: < /p>

Array
(
[0] => Array
(
[Outcome] => 1
[Bookmaker] => PaddyPower
[Updated] => 2015-01-19T09:28:36
[Bet] => 1
[SP] => 4/5
[CP] => 17/20
[line] =>
[Decimal] => 0.85
)

[1] => Array
(
[Outcome] => 1
[Bookmaker] => BetFair
[Updated] => 2015-01-19T09:59:12
[Bet] => 1
[SP] => 1/25
[CP] => 43/50
[line] =>
[Decimal] => 0.86
)

[2] => Array
(
[Outcome] => 1
[Bookmaker] => BetVictor
[Updated] => 2015-01-19T10:29:38
[Bet] => 1
[SP] => 869/1000
[CP] => 869/1000
[line] =>
[Decimal] => 0.87
)

[3] => Array
(
[Outcome] => 1
[Bookmaker] => BetFred
[Updated] => 2015-01-19T09:28:30
[Bet] => 1
[SP] => 4/5
[CP] => 17/20
[line] =>
[Decimal] => 0.85
)

[4] => Array
(
[Outcome] => 1
[Bookmaker] => CoralBet
[Updated] => 2015-01-19T09:28:36
[Bet] => 1
[SP] => 73/100
[CP] => 83/100
[line] =>
[Decimal] => 0.83
)

[5] => Array
(
[Outcome] => 1
[Bookmaker] => Bet365
[Updated] => 2015-01-19T09:35:59
[Bet] => 1
[SP] => 73/100
[CP] => 83/100
[line] =>
[Decimal] => 0.83
)

[6] => Array
(
[Outcome] => 1
[Bookmaker] => WilliamHill
[Updated] => 2015-01-19T09:48:17
[Bet] => 1
[SP] => 4/5
[CP] => 83/100
[line] =>
[Decimal] => 0.83
)

[7] => Array
(
[Outcome] => 1
[Bookmaker] => SkyBet
[Updated] => 2015-01-19T09:29:48
[Bet] => 1
[SP] => 67/100
[CP] => 83/100
[line] =>
[Decimal] => 0.83
)

[8] => Array
(
[Outcome] => 1
[Bookmaker] => Ladbrokes
[Updated] => 2015-01-19T09:29:48
[Bet] => 1
[SP] => 3/4
[CP] => 4/5
[line] =>
[Decimal] => 0.8
)

)
< /code>

Und ich versuche, es nach dem Wert "Dezimal" zu sortieren. < /p>

Ich habe eine Funktion erstellt Eine Sortierung nach dem Dezimalwert zu machen, aber aus irgendeinem Grund, wie Sie durch mein obiges Array sehen können, ist es nicht ganz sortiert, in dem 0,86 ein besserer Wert als 0,85 ist. />usort($outcomes, 'sort_by_decimal');
function sort_by_decimal ($a, $b)
{
return $a['Decimal'] - $b['Decimal'];
}
< /code>

Danke. < /p>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post