Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Sortowanie tablicy
Forum PHP.pl > Forum > PHP
nikolatesla
Witam. Mam posortowaną tablicę obiektów po punktach. Jak posortować kluby po różnicy bramek gdy kilka klubów będzie mieć tyle samo punktów? Bardzo proszę o pomoc.

  1. array(14) {
  2. [0] => object(Table)#57 (6) {
  3. ["id"] => string(1) "1"
  4. ["name"] => string(9) "clubName0"
  5. ["points"] => int(54)
  6. ["scoredGoals"] => int(77)
  7. ["lostGoals"] => int(26)
  8. ["goalOdds"] => int(51)
  9. }
  10. [1] => object(Table)#58 (6) {
  11. ["id"] => string(1) "2"
  12. ["name"] => string(9) "clubName1"
  13. ["points"] => int(44)
  14. ["scoredGoals"] => int(65)
  15. ["lostGoals"] => int(38)
  16. ["goalOdds"] => int(27)
  17. }
  18. [2] => object(Table)#85 (6) {
  19. ["id"] => string(1) "3"
  20. ["name"] => string(9) "clubName2"
  21. ["points"] => int(42)
  22. ["scoredGoals"] => int(59)
  23. ["lostGoals"] => int(39)
  24. ["goalOdds"] => int(20)
  25. }
  26. [3] => object(Table)#87 (6) {
  27. ["id"] => string(1) "4"
  28. ["name"] => string(9) "clubName3"
  29. ["points"] => int(41)
  30. ["scoredGoals"] => int(50)
  31. ["lostGoals"] => int(37)
  32. ["goalOdds"] => int(13)
  33. }
  34. [4] => object(Table)#89 (6) {
  35. ["id"] => string(1) "5"
  36. ["name"] => string(9) "clubName4"
  37. ["points"] => int(38)
  38. ["scoredGoals"] => int(66)
  39. ["lostGoals"] => int(43)
  40. ["goalOdds"] => int(23)
  41. }
  42. [5] => object(Table)#93 (6) {
  43. ["id"] => string(1) "7"
  44. ["name"] => string(9) "clubName6"
  45. ["points"] => int(33)
  46. ["scoredGoals"] => int(44)
  47. ["lostGoals"] => int(47)
  48. ["goalOdds"] => int(-3)
  49. }
  50. [6] => object(Table)#99 (6) {
  51. ["id"] => string(2) "10"
  52. ["name"] => string(9) "clubName9"
  53. ["points"] => int(32)
  54. ["scoredGoals"] => int(54)
  55. ["lostGoals"] => int(65)
  56. ["goalOdds"] => int(-11)
  57. }
  58. [7] => object(Table)#91 (6) {
  59. ["id"] => string(1) "6"
  60. ["name"] => string(9) "clubName5"
  61. ["points"] => int(31)
  62. ["scoredGoals"] => int(50)
  63. ["lostGoals"] => int(49)
  64. ["goalOdds"] => int(1)
  65. }
  66. [8] => object(Table)#95 (6) {
  67. ["id"] => string(1) "8"
  68. ["name"] => string(9) "clubName7"
  69. ["points"] => int(30)
  70. ["scoredGoals"] => int(39)
  71. ["lostGoals"] => int(45)
  72. ["goalOdds"] => int(-6)
  73. }
  74. [9] => object(Table)#103 (6) {
  75. ["id"] => string(2) "12"
  76. ["name"] => string(10) "clubName11"
  77. ["points"] => int(29)
  78. ["scoredGoals"] => int(54)
  79. ["lostGoals"] => int(71)
  80. ["goalOdds"] => int(-17)
  81. }
  82. [10] => object(Table)#97 (6) {
  83. ["id"] => string(1) "9"
  84. ["name"] => string(9) "clubName8"
  85. ["points"] => int(27)
  86. ["scoredGoals"] => int(45)
  87. ["lostGoals"] => int(67)
  88. ["goalOdds"] => int(-22)
  89. }
  90. [11] => object(Table)#101 (6) {
  91. ["id"] => string(2) "11"
  92. ["name"] => string(10) "clubName10"
  93. ["points"] => int(26)
  94. ["scoredGoals"] => int(49)
  95. ["lostGoals"] => int(87)
  96. ["goalOdds"] => int(-38)
  97. }
  98. [12] => object(Table)#105 (6) {
  99. ["id"] => string(2) "13"
  100. ["name"] => string(10) "clubName12"
  101. ["points"] => int(24)
  102. ["scoredGoals"] => int(36)
  103. ["lostGoals"] => int(73)
  104. ["goalOdds"] => int(-37)
  105. }
  106. [13] => object(Table)#107 (6) {
  107. ["id"] => string(2) "14"
  108. ["name"] => string(10) "clubName13"
  109. ["points"] => int(22)
  110. ["scoredGoals"] => int(64)
  111. ["lostGoals"] => int(65)
  112. ["goalOdds"] => int(-1)
  113. }
  114. }
c1chy
usort możesz skorzystać z tej funkcji
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.