Skip to content

Instantly share code, notes, and snippets.

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 pedrotnascimento/3b2f464f1206308d84c2388de710739b to your computer and use it in GitHub Desktop.
Save pedrotnascimento/3b2f464f1206308d84c2388de710739b to your computer and use it in GitHub Desktop.
util para transformar headers de csv em parâmetros de json sem espaço e com camelCase
for(i in params){
i = i.replace(/[A-Z]/,function(match){
return match.toLowerCase();
});
i = i.replace(/[ ][A-z]/g,function(match,offset,string){
return ""+string[offset+1].toUpperCase() ;
});
//insertion sort que recebe json e ordena a partir de um parametro
function insertionSort(arr, param){
var i =0;
// console.log(arr);
while(i < arr.length-1){
var j = i +1;
while( j> 0 && arr[j][param] < arr[j-1][param]){
var temp = arr[j];
arr[j]= arr[j-1];
arr[j-1] = temp;
j--;
}
i++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment