Classificando por dois campos em Clojure

Supondo que você tenha dados representados por um vetor de mapas: (def data [{:lastname “Brown” :firstname “John”} {:lastname “Brown” :firstname “Jack”} {:lastname “Apple” :firstname “Bruce”} {:lastname “Crown” :firstname “King”}]) Para …

Continuar lendo

O poder da programação funcional

Dado isso: var s = “|L0011|0||BOOKED||To Be Paid Off|4453731.62|0|4||L0011|||L0011|MTG|44|CD|5.500%|09/01/16|04/28/06|44944.32|4650000|4453731.62|4650000<br>|L0013|0||BOOKED||Partial|102731.6|0|4||L0013|||L0013|MTG|44|CD|4.150%|11/01/15|01/15/07|2632.39|229004|102731.6|111768.94<br>|L0017|0||BOOKED||Other|11731845.23|0|4||L0017|||L0017|MTG|44|CD|6.025%|06/01/12|06/01/07|125463.07|14838606|11731845.23|14838606<br>|L0003|0||BOOKED|X|*|486636.93|0|4||L0003|||L0003|MTG|44|CD|5.450%|02/01/16|01/16/04|4440.97|1471875|486636.93|519009.7<br>|L0021|0||BOOKED||Cash Secured|6268274.18|0|4||L0021|||L0021|MTG|44|CD|0.750%|01/01/13|01/31/11|48689.83|6740078|6268274.18|6384189.98<br>”; Disto: var sortThis = function(){ //create an array containing column 2 for (i=0; i < rows.length; i++) { var col2 …

Continuar lendo

Classificando uma matriz de objetos em Javascript

http://www.javascriptkit.com/javatutors/arraysort2.shtml var employees=[];employees[0]={name:”George”, age:32, retiredate:”March 12, 2014″};employees[1]={name:”Edward”, age:17, retiredate:”June 2, 2023″};employees[2]={name:”Christine”, age:58, retiredate:”December 20, 2036″};employees[3]={name:”Sarah”, age:62, retiredate:”April 30, 2020″};employees.sort(function(a, b){ var nameA=a.name.toLowerCase(), nameB=b.name.toLowerCase() if (nameA < nameB) //sort string ascending …

Continuar lendo