All pastes #1381 Raw Edit

S hr kan se ut.

public ruby v1 · immutable
#1381 ·published 2004-10-11 14:08 UTC
rendered paste body
#!/usr/bin/env rubyrequire 'pp'class Song   attr_reader :name, :pos   def initialize(name, pos)      @name = name      @pos  = pos   end   def <=>(other)      if(@pos < other.pos)         return -1      elsif(@pos == other.pos)         return 0      elsif(@pos > other.pos)         return 1      end        endendlist = []list << Song.new("abc", 5)list << Song.new("bcd", 2)list << Song.new("cde", 1)list << Song.new("def", 3)list << Song.new("efg", 4)pp list.sort