code: @SuppressWarnings("unchecked")
      public static <T extends Number & Comparable> T median(Collection<T> values) {
          if (values.isEmpty())
              throw new IllegalArgumentException(
                  "No median in an empty collection");
          List<T> sorted = new ArrayList<T>(values);
          
          Collections.sort(sorted);
          return sorted.get(sorted.size() / 2);
      }
docs: Returns the median value of the collection of numbers