JSFiddle - React, Tailwind, and code Playground
JavaScript
var sortByOpponent = function(games) {
// Loop through the array:
// Declare a variable to store the smallest element:
// Loop through the array again, looking for the smallest
// element that has not been put in the correct position:
// Swap the smallest element with the current element:
};
var games = [
{ score: [4, 1], opponent: "Oakland" },
{ score: [1, 0], opponent: "Illinois State" },
{ score: [5, 2], opponent: "TCU" },
{ score: [3, 1], opponent: "Saint Louis" },
{ score: [1, 2], opponent: "Washington" },
{ score: [1, 0], opponent: "Portland" },
{ score: [1, 0], opponent: "Northern Kentucky" },
{ score: [0, 0], opponent: "Indiana" },
{ score: [1, 3], opponent: "Purdue" },
{ score: [2, 1], opponent: "Rutgers" },
{ score: [2, 1], opponent: "Maryland" }
];
sortByOpponent(games);
var s = "[\n";
for (var i = 0; i < games.length; i++) {
s += " " + JSON.stringify(games[i]) + "\n";
}
s += "]";
alert("Order after calling sortByOpponent:\n" + s);