When the sorting algorithm compares the created arrays [Time.now <= cs.start_date, (cs.available || 0)], it compares them by elements.
The source elements are Boolean. There is no order for booleans.
irb(main):001:0> true <=> false
=> nil
You can get around this by creating integer values, for example.
[cs1, cs2, cs3, cs4, cs5].sort_by { |cs| [Time.now <= cs.start_date ? 0 : 1, (cs.available || 0)] }
source
share