<commit_before><!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<head>
<style>
 tr:nth-child(even){
  background: lightgrey;
 }
 td{
  text-align: center;
  border: 2px solid grey;
 }
 table{
  border-collapse: collapse;
 }
 th{
  border:2px solid grey;
 }
 table.caption{
  
 }
</style>
</head>
  <body>
    <script src="http://d3js.org/d3.v3.min.js"></script>
    <script>
      gdp_format = d3.format(".2s");
      life_expectancy_format = d3.format(".1f");
      population_format = d3.format(",");

      d3.json("data/countries_2012.json", function(error, data){

        var columns = ["name", "continent", "gdp", "life_expectancy", "population", "year"];

        var table = d3.select("body").append("table"),
          thead = table.append("thead")
                       .attr("class", "thead");
          tbody = table.append("tbody");

        table.append("caption")
          .html("World Countries Ranking");

        thead.append("tr").selectAll("th")
          .data(columns)
        .enter()
          .append("th")
          .text(function(d) { return d; })
          .on("click", function(header, i) {
            tbody.selectAll("tr").sort(function(a, b) {
              return d3.descending(a[header], b[header]);
            });
          });

        var rows = tbody.selectAll("tr.row")
          .data(data)
          .enter()
          .append("tr").attr("class", "row");

        var cells = rows.selectAll("td")
          .data(function(row) {
              return d3.range(columns.length).map(function(column, i) {
		  var result = row[Object.keys(row)[Object.keys(row).indexOf(columns[i])]];
		  if(columns[i] == "gdp"){
		   result = gdp_format(result);
                  }
		  else if(columns[i] == "life_expectancy"){
		   result = life_expectancy_format(result);
		  }
		  else if(columns[i] == "population"){
		   result = population_format(result);
		  }
                  return result;
              });
          })
          .enter()
          .append("td")
          .text(function(d) { return d; })

      });
    </script> 
  </body>
</html><commit_msg>Sorting<commit_after><!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<head>
<style>
 tr:nth-child(even){
  background: lightgrey;
 }
 td{
  text-align: center;
  border: 2px solid grey;
 }
 table{
  border-collapse: collapse;
 }
 th{
  border:2px solid grey;
 }
</style>
</head>
  <body>
    <script src="http://d3js.org/d3.v3.min.js"></script>
    <script>
      //===formatters===
      gdp_format = d3.format(".2s");
      life_expectancy_format = d3.format(".1f");
      population_format = d3.format(",");

      d3.json("data/countries_2012.json", function(error, data){

	  columns = ["name", "continent", "gdp", "life_expectancy", "population", "year"];

          var table = d3.select("body").append("table"),
          thead = table.append("thead")
                       .attr("class", "thead");
          tbody = table.append("tbody");

        table.append("caption")
          .html("World Countries Ranking");

        thead.append("tr").selectAll("th")
          .data(columns)
        .enter()
          .append("th")
          .text(function(d) { return d; })
          .on("click", function(header, i) {
	    sort_column = header;
	    sort_ascending = !sort_ascending;
	    Sorting(header);
	  });

        var rows = tbody.selectAll("tr.row")
          .data(data)
          .enter()
          .append("tr").attr("class", "row");

        var cells = rows.selectAll("td")
          .data(function(row) {
              return d3.range(columns.length).map(function(column, i) {
		  var result = row[Object.keys(row)[Object.keys(row).indexOf(columns[i])]];
		  if(columns[i] == "gdp"){
		   result = gdp_format(result);
                  }
		  else if(columns[i] == "life_expectancy"){
		   result = life_expectancy_format(result);
		  }
		  else if(columns[i] == "population"){
		   result = population_format(result);
		  }
                  return result;
              });
          })
          .enter()
          .append("td")
          .text(function(d) { return d; })

      });

      //===sorting===
      //sort_column = null;
      sort_ascending = false;
      function Sorting(header){
       /*
       thead.append("tr").selectAll("th")
       .data(columns)
       .enter()
       .append("th")
       .text(function(d){
        if(d == sort_column){
         if(sort_ascending){
          return d + "&#9650;";
         }
         else{
          return d + "&#9660;";
         }
        }
        else{
         return d;
        }
       });
       */
       tbody.selectAll("tr").sort(function(a, b) {
       return sort_ascending ? d3.ascending(a[header], b[header]) : d3.descending(a[header], b[header]);
       });
      }
    </script> 
  </body>
</html>
{'fraction_non_alphanumeric': 0.17941787941787943, 'fraction_numerical': 0.009771309771309772, 'mean_word_length': 2.0449367088607593, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1821142', 'n_tokens_mistral': 1641, 'n_tokens_neox': 1531, 'n_words': 267}