Skip to content

Instantly share code, notes, and snippets.

@Ghost---Shadow
Created July 28, 2017 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ghost---Shadow/4787671b4d37f5d77ea73cad71a46b15 to your computer and use it in GitHub Desktop.
Save Ghost---Shadow/4787671b4d37f5d77ea73cad71a46b15 to your computer and use it in GitHub Desktop.
var students = [];
var rows = $("tr");
for(var i = 1; i < rows.length; i++){
students[i-1] = {};
var row = rows[i];
var name = (row.children[0].innerHTML+"").trim();
students[i-1]["name"] = name.replace("&nbsp;","").replace(/\s\s+/g,' ');
var cgpa = (row.children[3].innerHTML+"").trim();
students[i-1]["cgpa"] = parseFloat(cgpa);
var place = (row.children[4].innerHTML+"").trim();
students[i-1]["place"] = place;
var registration = (row.children[2].children[0].innerHTML+"").trim()
students[i-1]["registration"] = registration;
}
students.sort(function(a,b){return b.cgpa - a.cgpa});
var target = /^Souradeep/i;
for(var i = 0; i < students.length; i++){
if(students[i].name.search(target) > -1)
console.log(i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment