Tabnine Logo
Arrays.sort
Code IndexAdd Tabnine to your IDE (free)

How to use
sort
method
in
java.util.Arrays

Best Java code snippets using java.util.Arrays.sort (Showing top 20 results out of 37,548)

Refine searchRefine arrow

  • PrintStream.println
  • List.size
  • List.add
  • List.toArray
  • Arrays.binarySearch
  • Set.toArray
  • List.get
  • Arrays.toString
  • Map.keySet
origin: apache/flink

private static int[] toFieldPosMap(int[] selectedFields) {
  int[] fieldIdxs = Arrays.copyOf(selectedFields, selectedFields.length);
  Arrays.sort(fieldIdxs);
  int[] fieldPosMap = new int[selectedFields.length];
  for (int i = 0; i < selectedFields.length; i++) {
    int pos = Arrays.binarySearch(fieldIdxs, selectedFields[i]);
    fieldPosMap[pos] = i;
  }
  return fieldPosMap;
}
origin: stackoverflow.com

 import java.util.Arrays;

public class Test
{
  public static void main(String[] args)
  {
    String original = "edcba";
    char[] chars = original.toCharArray();
    Arrays.sort(chars);
    String sorted = new String(chars);
    System.out.println(sorted);
  }
}
origin: google/guava

/**
 * Returns a copy of {@code multiset} as an {@link ImmutableMultiset} whose iteration order is
 * highest count first, with ties broken by the iteration order of the original multiset.
 *
 * @since 11.0
 */
@Beta
public static <E> ImmutableMultiset<E> copyHighestCountFirst(Multiset<E> multiset) {
 Entry<E>[] entries = (Entry<E>[]) multiset.entrySet().toArray(new Entry[0]);
 Arrays.sort(entries, DecreasingCount.INSTANCE);
 return ImmutableMultiset.copyFromEntries(Arrays.asList(entries));
}
origin: org.apache.lucene/lucene-core

private static String[] listAll(Path dir, Set<String> skipNames) throws IOException {
 List<String> entries = new ArrayList<>();
 
 try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) {
  for (Path path : stream) {
   String name = path.getFileName().toString();
   if (skipNames == null || skipNames.contains(name) == false) {
    entries.add(name);
   }
  }
 }
 
 String[] array = entries.toArray(new String[entries.size()]);
 // Directory.listAll javadocs state that we sort the results here, so we don't let filesystem
 // specifics leak out of this abstraction:
 Arrays.sort(array);
 return array;
}
origin: google/ExoPlayer

/**
 * @param cues A list of the cues in this subtitle.
 */
public WebvttSubtitle(List<WebvttCue> cues) {
 this.cues = cues;
 numCues = cues.size();
 cueTimesUs = new long[2 * numCues];
 for (int cueIndex = 0; cueIndex < numCues; cueIndex++) {
  WebvttCue cue = cues.get(cueIndex);
  int arrayIndex = cueIndex * 2;
  cueTimesUs[arrayIndex] = cue.startTime;
  cueTimesUs[arrayIndex + 1] = cue.endTime;
 }
 sortedCueTimesUs = Arrays.copyOf(cueTimesUs, cueTimesUs.length);
 Arrays.sort(sortedCueTimesUs);
}
origin: ltsopensource/light-task-scheduler

Arrays.sort(logFiles, new Comparator<String>() {
  @Override
  public int compare(String left, String right) {
      storeConfig, new File(logPath, logFile), !isWritable, false, 0);
  if (i > 1) {
    storeTxLogs.get(i - 1).setNext(storeTxLog);
  storeTxLogs.add(storeTxLog);
storeTxLogs.add(storeTxLog);
origin: redisson/redisson

public FSTFieldInfo[] getFieldArray() {
  if (infoArr == null) {
    List<FSTClazzInfo.FSTFieldInfo> fields = getFields();
    final FSTFieldInfo[] fstFieldInfos = new FSTFieldInfo[fields.size()];
    fields.toArray(fstFieldInfos);
    Arrays.sort(fstFieldInfos, defFieldComparator);
    infoArr = fstFieldInfos;
  }
  return infoArr;
}
origin: AdoptOpenJDK/jitwatch

public List<IMetaMember> getMetaMembers()
{
  List<IMetaMember> result = new ArrayList<>();
  IMetaMember[] constructorsArray = classConstructors.toArray(new IMetaMember[classConstructors.size()]);
  Arrays.sort(constructorsArray);
  IMetaMember[] methodsArray = classMethods.toArray(new IMetaMember[classMethods.size()]);
  Arrays.sort(methodsArray);
  result.addAll(Arrays.asList(constructorsArray));
  result.addAll(Arrays.asList(methodsArray));
  return result;
}
origin: wildfly/wildfly

} else {
  List<Cookie> cookiesList = InternalThreadLocalMap.get().arrayList();
  cookiesList.add(firstCookie);
  while (cookiesIt.hasNext()) {
    cookiesList.add(cookiesIt.next());
  Cookie[] cookiesSorted = cookiesList.toArray(new Cookie[0]);
  Arrays.sort(cookiesSorted, COOKIE_COMPARATOR);
  for (Cookie c : cookiesSorted) {
    encode(buf, c);
origin: apache/hive

ts.add(tableBaseName + "1");
ts.add(tableBaseName + "2");
Table tbl1 = createTestTable(dbName, ts.get(0));
hm.createTable(tbl1);
Table tbl2 = createTestTable(dbName, ts.get(1));
hm.createTable(tbl2);
Table table1 = hm.getTable(dbName, ts.get(0));
assertNotNull(table1);
assertEquals(ts.get(0), table1.getTableName());
assertTrue(fs.exists(path2));
Path trash2 = mergePaths(trashDir, path2);
System.out.println("trashDir2 is " + trash2);
pathglob = trash2.suffix("*");
before = fs.globStatus(pathglob);
assertFalse(fs.exists(path2));
after = fs.globStatus(pathglob);
Arrays.sort(before);
Arrays.sort(after);
assertEquals("trash dir before and after DROP TABLE PURGE are different",
       before.length, after.length);
System.err.println(StringUtils.stringifyException(e));
System.err.println("testDropTableTrash() failed");
throw e;
origin: spring-projects/spring-framework

Constructor<?>[] ctors = type.getConstructors();
Arrays.sort(ctors, (c1, c2) -> {
  int c1pl = c1.getParameterCount();
  int c2pl = c2.getParameterCount();
  List<TypeDescriptor> paramDescriptors = new ArrayList<>(paramTypes.length);
  for (int i = 0; i < paramTypes.length; i++) {
    paramDescriptors.add(new TypeDescriptor(new MethodParameter(ctor, i)));
  if (ctor.isVarArgs() && argumentTypes.size() >= paramTypes.length - 1) {
  else if (paramTypes.length == argumentTypes.size()) {
origin: org.postgresql/postgresql

@Override
public ResultSet getTableTypes() throws SQLException {
 String[] types = tableTypeClauses.keySet().toArray(new String[0]);
 Arrays.sort(types);
 Field[] f = new Field[1];
 List<byte[][]> v = new ArrayList<byte[][]>();
 f[0] = new Field("TABLE_TYPE", Oid.VARCHAR);
 for (String type : types) {
  byte[][] tuple = new byte[1][];
  tuple[0] = connection.encodeString(type);
  v.add(tuple);
 }
 return ((BaseStatement) createMetaDataStatement()).createDriverResultSet(f, v);
}
origin: pentaho/pentaho-kettle

@Override
public String[] listParameters() {
 Set<String> keySet = params.keySet();
 String[] paramArray = keySet.toArray( new String[0] );
 Arrays.sort( paramArray );
 return paramArray;
}
origin: jiajunhui/PlayerBase

public void registerOnGroupValueUpdateListener(
    IReceiverGroup.OnGroupValueUpdateListener onGroupValueUpdateListener){
  if(mOnGroupValueUpdateListeners.contains(onGroupValueUpdateListener))
    return;
  mOnGroupValueUpdateListeners.add(onGroupValueUpdateListener);
  //sort it for Arrays.binarySearch();
  String[] keyArrays = onGroupValueUpdateListener.filterKeys();
  Arrays.sort(keyArrays);
  mListenerKeys.put(onGroupValueUpdateListener, keyArrays);
  //when listener add, if user observe keys in current KeySet, call back it.
  checkCurrentKeySet(onGroupValueUpdateListener);
}
origin: h2oai/h2o-2

private void sampleThresholds(int yi){
 _ti[yi] = (_newThresholds[yi].length >> 2);
 try{ Arrays.sort(_newThresholds[yi]);} catch(Throwable t){
  System.out.println("got AIOOB during sort?! ary = " + Arrays.toString(_newThresholds[yi]));
  return;
 } // sort throws AIOOB sometimes!
 for (int i = 0; i < _newThresholds.length; i += 4)
  _newThresholds[yi][i >> 2] = _newThresholds[yi][i];
}
@Override public void processRow(long gid, final double [] nums, final int ncats, final int [] cats, double [] responses /* time...*/){
origin: org.apache.logging.log4j/log4j-core

static void assertFileContents(final int runNumber) throws IOException {
  final Path path = Paths.get(FOLDER + "/audit.tmp");
  final List<String> lines = Files.readAllLines(path, Charset.defaultCharset());
  int i = 1;
  final int size = lines.size();
  for (final String string : lines) {
    if (string.startsWith(",,")) {
      final Path folder = Paths.get(FOLDER);
      final File[] files = folder.toFile().listFiles();
      Arrays.sort(files);
      System.out.println("Run " + runNumber + ": " + Arrays.toString(files));
      Assert.fail(
          String.format("Run %,d, line %,d of %,d: \"%s\" in %s", runNumber, i++, size, string, lines));
    }
  }
}
origin: jMonkeyEngine/jmonkeyengine

public void print(){
  System.out.println("-----------------");
  Set<Integer> keys = objs.keySet();
  Integer[] keysArr = keys.toArray(new Integer[0]);
  Arrays.sort(keysArr);
  for (int i = 0; i < keysArr.length; i++){
    System.out.println(keysArr[i]+" => "+objs.get(keysArr[i]).hashCode());
  }
}
origin: sannies/mp4parser

  public static void main(String[] args) throws IOException {
    IsoFile isofile = new IsoFile("C:\\content\\bbb-small\\output_320x180-mjpeg.mp4");
    ESDescriptorBox esDescriptorBox = Path.getPath(isofile, "/moov[0]/trak[0]/mdia[0]/minf[0]/stbl[0]/stsd[0]/mp4v[0]/esds[0]");
    byte[] d = new byte[esDescriptorBox.getData().rewind().remaining()];
    esDescriptorBox.getData().get(d);
    System.err.println(Hex.encodeHex(d));

    Movie mRef = MovieCreator.build("C:\\content\\bbb-small\\output_320x180_150.mp4");
    Track refTrack = mRef.getTracks().get(0);

    File baseDir = new File("C:\\content\\bbb-small");
    File[] iFrameJpegs = baseDir.listFiles(new FilenameFilter() {
      public boolean accept(File dir, String name) {
        return name.endsWith(".jpg");
      }
    });
    Arrays.sort(iFrameJpegs);

    Movie mRes = new Movie();
    mRes.addTrack(new OneJpegPerIframe("iframes", iFrameJpegs, refTrack));

    new DefaultMp4Builder().build(mRes).writeContainer(new FileOutputStream("output-mjpeg.mp4").getChannel());
  }
}
origin: apache/drill

   out.print(indentString(indent));
   if (appendToHeader != null && !appendToHeader.isEmpty()) {
    out.println(xpl_note.displayName() + appendToHeader);
   } else {
    out.println(xpl_note.displayName());
     if (outputOperators != null) {
      ((JSONObject) jsonOut.get(JSONObject.getNames(jsonOut)[0])).put(OUTPUT_OPERATORS,
        Arrays.toString(outputOperators.toArray()));
Arrays.sort(methods, new MethodComparator());
      out.print(" ");
     out.println(val);
origin: h2oai/h2o-2

 System.out.println("lower bounds = " + Arrays.toString(_lbs));
 if(_srcDinfo._normMul != null) {
  for (int i = numoff; i < _srcDinfo.fullN(); ++i) {
System.out.println("lbs = " + Arrays.toString(_lbs));
if((v = beta_constraints.vec("upper_bounds")) != null) {
 _ubs = map == null ? Utils.asDoubles(v) : mapVec(Utils.asDoubles(v), makeAry(names.length, Double.POSITIVE_INFINITY), map);
 System.out.println("upper bounds = " + Arrays.toString(_ubs));
 throw new IllegalArgumentException("Missing vector of penalties (rho) in beta_constraints file.");
String [] cols = new String[]{"names","rho","beta_given","lower_bounds","upper_bounds"};
Arrays.sort(cols);
for(String str:beta_constraints.names())
 if(Arrays.binarySearch(cols,str) < 0)
  Log.warn("unknown column in beta_constraints file: '"  + str + "'");
java.utilArrayssort

Javadoc

Sorts the specified array in ascending numerical order.

Popular methods of Arrays

  • asList
    Returns a List of the objects in the specified array. The size of the List cannot be modified, i.e.
  • toString
    Returns a string representation of the contents of the specified array. The string representation co
  • equals
    Returns true if the two specified arrays of booleans areequal to one another. Two arrays are conside
  • copyOf
    Copies the specified array, truncating or padding with false (if necessary) so the copy has the spec
  • fill
    Assigns the specified boolean value to each element of the specified array of booleans.
  • stream
  • hashCode
    Returns a hash code based on the contents of the specified array. For any two boolean arrays a and
  • copyOfRange
    Copies the specified range of the specified array into a new array. The initial index of the range (
  • binarySearch
    Searches the specified array of shorts for the specified value using the binary search algorithm. Th
  • deepEquals
    Returns true if the two specified arrays are deeply equal to one another. Unlike the #equals(Object[
  • deepToString
  • deepHashCode
    Returns a hash code based on the "deep contents" of the specified array. If the array contains other
  • deepToString,
  • deepHashCode,
  • setAll,
  • parallelSort,
  • parallelSetAll,
  • spliterator,
  • checkBinarySearchBounds,
  • checkOffsetAndCount,
  • checkStartAndEnd

Popular in Java

  • Creating JSON documents from java classes using gson
  • runOnUiThread (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • startActivity (Activity)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • JButton (javax.swing)
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now