Last active
April 24, 2017 00:29
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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