Beispiel #1
0
 private void sort() {
   Collections.sort(
       array_,
       new Comparator /*<RubyValue>*/() {
         public int compare(Object /*RubyValue*/ arg0, Object /*RubyValue*/ arg1) {
           RubyValue v =
               RubyAPI.callPublicOneArgMethod(
                   (RubyValue) arg0, (RubyValue) arg1, null, RubyID.unequalID);
           return ((RubyFixnum) v).toInt();
         }
       });
 }
Beispiel #2
0
  private void sort_with_block(final RubyBlock block) {
    final RubyArray self = this;
    Collections.sort(
        array_,
        new Comparator /*<RubyValue>*/() {

          public int compare(Object /*RubyValue*/ arg0, Object /*RubyValue*/ arg1) {
            // TODO can not check if block return/break occured.
            RubyValue v = block.invoke(self, (RubyValue) arg0, (RubyValue) arg1);
            return ((RubyFixnum) v).toInt();
          }
        });
  }