CoffeeScript sorting

by alexbfree

CoffeeScript

season0 =
  season: '0'
  label: "Lost Season"
season1 =
  season: '1'
  label: "Season 1"
season2 =
  season: '2'
  label: "Season 2"
season3 =
  season: '3'
  label: "Season 3"
season6 =
  season: '6'
  label: "Season6"
sortedSeasons = [season6,season1,season3,season2,season0]
sortedSeasons.sort (a, b) ->
  if a.season is '0'
    4.5 - b.season
  else if b.season is '0'
    a.season - 4.5
  else
    a.season - b.season
    
console.log sortedSeasons