JSFiddle - React, Tailwind, and code Playground

by M Greene

JavaScript

var app = angular.module("sortingApp", []);

app.controller("bubbleSortController", ['$scope', '$sce', function($scope, $sce) {
	$scope.pageHeader = "Bubble Sort";
  $scope.pageDesc = "Implementation of the Bubble Sort algorithm (flipped values marked in green)";
  $scope.sortedArray = [[1,2,5,3,4], [1,2,3,5,4], [1,2,3,4,5]];

  $scope.getSortedTable = function(array) {
    var rows = "<tr>"

    //load first array
    for (var i=0; i< array[0].length; i++) {
      rows += "<td>" + array[0][i] + "</td>";
    }

    // check if integer pairs have been swapped
    for (var i = 1; i<array.length; i++) {
      rows += "</tr><tr>";

      for (var j = 0; j<array[i].length; j++) {
        rows += "<td" + ((array[i][j] != array[i-1][j]) ? " class='changed'>" : ">") + array[i][j] + "</td>";
      }
    }

    rows += "</tr>";

    console.log("rows:", rows);
    return $sce.trustAsHtml(rows);
  };
    
    
}]);

app.directive("directive", function() {
	return {template: "I'm a directive dur dur dur!"};
});