title: Understanding Scala Ordered[ ] trait to compare reference
body: <p>Currently, I am learning Scala and now, I am having some confusions understanding Ordered traits to compare object. </p>
  
  <p>Consider following example, which are my current understanding of comparing, </p>
  
  <pre><code>Case I,
  class Example(var n: Int) extends Ordered[Example] {
      // ...
      def compare(that: Example) =
      (this.n) - (that.n)
  }
  
  var obj1 = new Example(12)
  var obj2 = new Example(12)
  obj1 compare obj2 //return 0 i.e. obj1 and obj2 are equal.
  
  Case II,
  class Example(var m: Int, var n: Int) extends Ordered[Example] {
      // ...
      def compare(that: Example) =
      (this.m * this.n) - (that.m * that.n)
  }
  
  var obj1 = new Example(1, 2)
  var obj2 = new Example(1, 2)
  obj1 compare obj2 //return 0 i.e. obj1 and obj2 are equal.
  
  Case III,
  class Example(var name: String) extends Ordered[Example] {
      // ...
      def compare(that: Example) =
      this.name compare that.name
  }
  
  var obj1 = new Example("abc")
  var obj2 = new Example("abc)
  obj1 compare obj2 //return 0 i.e. obj1 and obj2 are equal.
  
  
  Case IV,
  class Example(var name1: String, var name2: String) extends Ordered[Example] {
      // ...
      def compare(that: Example) =
      (this.name1 + this.name2) compare (that.name1+that.name2)
  }
  
  var obj1 = new Example("abc","def")
  var obj2 = new Example("abc","def")
  obj1 compare obj2 //return 0 i.e. obj1 and obj2 are equal.
  </code></pre>
  
  <p>So, my questions is, what if there is non-constructor field in the class? for example, </p>
  
  <pre><code>class Example(var n: Int) extends Ordered[Example] {
      var someVar: String = "default";
      // ...
      def compare(that: Example) =
      (this.n) - (that.n)
      //do we also need to compare someVar???? otherwise, object will have different state right??
  }
  
  var obj1 = new Example(12)
  obj1.someVar = "value 1"
  var obj2 = new Example(12)
  obj2.someVar = "another value 2"
  obj1 compare obj2 //Again, return 0 i.e. obj1 and obj2 are equal.
  </code></pre>
  
  <p>Please, correct me if above understanding are wrong.</p>