public static Keyword medianOfNumbersSpecialist(ControlFrame frame, Keyword lastmove) {
    { Proposition proposition = frame.proposition;
      Stella_Object listarg = (proposition.arguments.theArray)[0];
      List sortlist = List.newList();
      Stella_Object listskolem = Logic.argumentBoundTo(listarg);
      Stella_Object medianarg = (proposition.arguments.theArray)[1];
      int numbercount = 0;
      NumberWrapper result = null;

      lastmove = lastmove;
      if ((listskolem != null) &&
          (!Logic.logicalCollectionP(listskolem))) {
        {
          System.out.println();
          System.out.println("Non list appears in second argument to 'MEDIAN-OF-NUMBERS'");
          System.out.println();
        }
;
        return (Logic.KWD_TERMINAL_FAILURE);
      }
      { List listvalue = Logic.assertedCollectionMembers(listskolem, true);

        if (listvalue.emptyP()) {
          return (Logic.KWD_TERMINAL_FAILURE);
        }
        { Stella_Object v = null;
          Cons iter000 = listvalue.theConsList;

          for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
            v = iter000.value;
            if (Stella_Object.isaP(v, Logic.SGT_STELLA_NUMBER_WRAPPER)) {
              sortlist.push(((NumberWrapper)(v)));
            }
            else {
              return (Logic.KWD_FAILURE);
            }
          }
        }
        numbercount = sortlist.length();
        if (numbercount == 0) {
          return (Logic.KWD_TERMINAL_FAILURE);
        }
        sortlist.sort(Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "arithmeticLessTest", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.NumberWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper")}));
        if (((numbercount % 2) == 1)) {
          result = ((NumberWrapper)(sortlist.nth(((int)((numbercount - 1) / 2.0)))));
        }
        else {
          result = PlKernelKb.divideComputation(PlKernelKb.plusComputation(((NumberWrapper)(sortlist.nth(((int)((numbercount / 2.0) - 1))))), ((NumberWrapper)(sortlist.nth(((int)(numbercount / 2.0)))))), IntegerWrapper.wrapInteger(2));
        }
        return (Logic.selectTestResult(Logic.bindArgumentToValueP(medianarg, result, true), true, frame));
      }
    }
  }