A Pen by Joe Chimienti on CodePen.
Created
August 8, 2016 19:20
-
-
Save j-chimienti/d1a28dd940c64e29ea442966b21abecb to your computer and use it in GitHub Desktop.
sort
This file contains hidden or 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
| var quotes = [ | |
| { quote: 'The lessons we remember are the lessons we learn the hard way', | |
| author: 'Seth Godin' | |
| }, | |
| { | |
| quote: 'Anything worth doing is worth doing slowly', | |
| author: 'Mae West' | |
| }, { | |
| quote: 'The things you own end up owning you. It is only after you lose everything that you are free to do anything.', | |
| author: 'Chuck Palahniuk ' | |
| }, { | |
| quote: 'Great minds discuss ideas; average minds discuss events; small minds discuss people', | |
| author: 'Elanor Roosevelt' | |
| }, { | |
| quote: 'Service to others is the rent you pay for your room here on earth.', | |
| author: 'Muhammad Ali' | |
| }, { | |
| quote: "Compound interest is the eighth wonder of the world. He who understands it, earns it ... he who doesn't ... pays it.", | |
| author: "Albert Einstein" | |
| }, { | |
| quote: "Tell me and I'll forget; show me and I may remember; involve me and I'll understand", | |
| author: "Chinese Proverb" | |
| }, { | |
| quote: "Nobody can give you freedom. Nobody can give you equality or justice or anything. If you're a man, you take it", | |
| author: "Malcolm X" | |
| }, { | |
| quote: "A man is rich in proportion to the number of things he can afford to let alone", | |
| author: "Henry David Theroux" | |
| }, { | |
| quote: "What information consumes is rather obvious: it consumes the attention of its recipients. Hence, a wealth of information creates a poverty of attention and a need to allocate that attention efficiently among the overabundance of information sources that might consume it.", | |
| author: "Herbert Simon" | |
| }, { | |
| quote: "Reading, after a certain age, diverts the mind too much from its creative pursuits. Any man who reads too much and uses his own brain too little falls into lazy habits of thinking.", | |
| author: "Albert Einstein" | |
| }, | |
| //{quote: "Love of bustle is not industry." , author: "Seneca" }, | |
| { | |
| quote: "There are many things of which a wise man might wish to be ignorant.", | |
| author: "RALPH WALDO EMERSON (1803 1882)" | |
| }, { | |
| quote: "Learning to ignore things is one of the great paths to inner peace.", | |
| author: "Robert J. Sawyer, Calculating God" | |
| }, { | |
| quote: "An expert is a person who has made all the mistakes that can be made in a very narrow field.", | |
| author: "NIELS BOHR, Danish physicist and Nobel Prize winner" | |
| }, { | |
| quote: "Everything popular is wrong.", | |
| author: "OSCAR WILDE, The Importance of Being Earnest" | |
| }, { | |
| quote: "I can't give you a surefire formula for success, but I can give you a formula for failure: try to please everybody all the time.", | |
| author: "HERBERT BAYARD SWOPE, American editor and journalist; first recipient of the Pulitzer Prize" | |
| }, { | |
| quote: "Whenever you find yourself on the side of the majority, it is time to pause and reflect.", | |
| author: "Mark Twain" | |
| }, { | |
| quote: "Reality is merely an illusion, albeit a very persistent one .", | |
| author: "Albert Einstein" | |
| }, { | |
| quote: "These individuals have riches just as we say that we 'have a fever,' when really the fever has us.", | |
| author: "SENECA (4 B.C. A.D. 65)" | |
| }, { | |
| quote: "Meetings are an addictive, highly self indulgent activity that corporations and other organizations habitually engage in only because they cannot actually masturbate.", | |
| author: "DAVE BARRY, Pulitzer Prize winning American humorist" | |
| }, { | |
| quote: "The vision is really about empowering workers, giving them all the information about what's going on so they can do a lot more than they've done in the past.", | |
| author: "Bill Gates" | |
| }, { | |
| quote: "Anyone who lives within their means suffers from a lack of imagination.", | |
| author: "OSCAR WILDE, Irish dramatist and novelist" | |
| }, { | |
| quote: "The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man.", | |
| author: "George Bernard Shaw" | |
| }, { | |
| quote: "There is no way to happiness -- happiness is the way.", | |
| author: "Thich Nhat Hanh" | |
| }, { | |
| quote: "The simple willingness to improvise is more vital, in the long run, than research.", | |
| author: "Rolf Potts" | |
| }, { | |
| quote: "If you don’t make mistakes, you’re not working on hard enough problems. And that’s a big mistake.", | |
| author: "Frank Wilczek, 2004 Nobel Prize winner in physics" | |
| }, { | |
| quote: "All courses of action are risky, so prudence is not in avoiding danger (it’s impossible), but calculating risk and acting decisively. Make mistakes of ambition and not mistakes of sloth. Develop the strength to do bold things, not the strength to suffer.", | |
| author: "Niccolo Machiavelli, The Prince" | |
| } | |
| ]; | |
| var sortedQuotes = quotes.sort(by('author')); | |
| function by(property){ | |
| return function(a,b){ | |
| var v1 = a[property]; | |
| var v2 = b[property]; | |
| if ( v1 < v2){ | |
| return -1; | |
| }else if ( v1 > v2){ | |
| return 1; | |
| }else{ | |
| return 0; | |
| } | |
| } | |
| } | |
| console.log(sortedQuotes[0]) | |
| console.log(sortedQuotes[1]) | |
| console.log(sortedQuotes[2]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment