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

How to use
sort
method
in
java.util.ArrayList

Best Java code snippets using java.util.ArrayList.sort (Showing top 20 results out of 1,656)

origin: eclipse/eclipse-collections

/**
 * @since 10.0 - Override for correctness
 */
@Override
public void sort(Comparator<? super T> comparator)
{
  this.delegate.sort(comparator);
}
origin: eclipse/eclipse-collections

/**
 * Mutates the internal array of the ArrayList by sorting it and then returns the same ArrayList.
 */
public static <T> ArrayList<T> sortThis(ArrayList<T> list, Comparator<? super T> comparator)
{
  list.sort(comparator);
  return list;
}
origin: eclipse/eclipse-collections

/**
 * Mutates the internal array of the ArrayList by sorting it and then returns the same ArrayList.
 */
public static <T> ArrayList<T> sortThis(ArrayList<T> list, Comparator<? super T> comparator)
{
  list.sort(comparator);
  return list;
}
origin: eclipse/eclipse-collections

/**
 * @since 10.0 - Override for correctness
 */
@Override
public void sort(Comparator<? super T> comparator)
{
  this.delegate.sort(comparator);
}
origin: gocd/gocd

private StageIdFaninScmMaterialPair getSmallestScmRevision(Collection<StageIdFaninScmMaterialPair> scmWithDiffVersions) {
  ArrayList<StageIdFaninScmMaterialPair> materialPairList = new ArrayList<>(scmWithDiffVersions);
  materialPairList.sort((pair1, pair2) -> {
    final PipelineTimelineEntry.Revision rev1 = pair1.faninScmMaterial.revision;
    final PipelineTimelineEntry.Revision rev2 = pair2.faninScmMaterial.revision;
    return rev1.date.compareTo(rev2.date);
  });
  return materialPairList.get(0);
}
origin: neo4j/neo4j

public String usage()
{
  StringBuilder sb = new StringBuilder();
  if ( !namedArgs.isEmpty() )
  {
    sb.append( namedArgs.values().stream().map( NamedArgument::usage ).collect( Collectors.joining( " " ) ) );
  }
  if ( !positionalArgs.isEmpty() )
  {
    sb.append( " " );
    positionalArgs.sort( Comparator.comparingInt( PositionalArgument::position ) );
    sb.append( positionalArgs.stream().map( PositionalArgument::usage ).collect( Collectors.joining( " " ) ) );
  }
  return sb.toString().trim();
}
origin: gocd/gocd

@Override
public List<Revision> revisions() {
  ArrayList<Revision> revisions = new ArrayList<>(this.revisions);
  revisions.sort((o1, o2) -> ((PipelineRevision) o1).compareTo((PipelineRevision) o2));
  return revisions;
}
origin: gocd/gocd

@Override
public List<Revision> revisions() {
  ArrayList<Revision> revisions = new ArrayList<>(this.revisions);
  for(MaterialRevision revision : materialRevisions) {
    for(Modification modification : revision.getModifications()) {
      revisions.add(new SCMRevision(modification));
    }
  }
  revisions.sort(Comparator.comparing(o -> ((SCMRevision) o)));
  return revisions;
}
origin: graphhopper/graphhopper

private Transfer findMostSpecificRule(List<Transfer> transfers, String fromRouteId, String toRouteId) {
  final ArrayList<Transfer> transfersBySpecificity = new ArrayList<>(transfers);
  transfersBySpecificity.sort(Comparator.comparingInt(t -> {
    int score = 0;
    if (fromRouteId.equals(t.from_route_id)) {
      score++;
    }
    if (toRouteId.equals(t.to_route_id)) {
      score++;
    }
    return -score;
  }));
  if (transfersBySpecificity.isEmpty()) {
    throw new RuntimeException();
  }
  return transfersBySpecificity.get(0);
}
origin: neo4j/neo4j

long send()
{
  // Sort in reverse, so the elements we want to send first are at the end.
  batches.sort( TICKETED_BATCH_COMPARATOR );
  long idleTimeSum = 0;
  long batchesDone = 0;
  for ( int i = batches.size() - 1; i >= 0 ; i-- )
  {
    TicketedBatch batch = batches.get( i );
    if ( batch.ticket == lastSendTicket + 1 )
    {
      batches.remove( i );
      lastSendTicket = batch.ticket;
      idleTimeSum += downstream.receive( batch.ticket, batch.batch );
      batchesDone++;
    }
    else
    {
      break;
    }
  }
  doneBatches.getAndAdd( batchesDone );
  return idleTimeSum;
}
origin: stanfordnlp/CoreNLP

/**
 * Returns an ordered list of edges in the graph.
 * This creates and sorts a list, so prefer edgeIterable().
 *
 * @return A ordered list of edges in the graph.
 */
public List<SemanticGraphEdge> edgeListSorted() {
 ArrayList<SemanticGraphEdge> edgeList = new ArrayList<>();
 for (SemanticGraphEdge edge : edgeIterable()) {
  edgeList.add(edge);
 }
 edgeList.sort(SemanticGraphEdge.orderByTargetComparator());
 return edgeList;
}
origin: jenkinsci/jenkins

/**
 * Gets all the users.
 */
public static @Nonnull
Collection<User> getAll() {
  final IdStrategy strategy = idStrategy();
  ArrayList<User> users = new ArrayList<>(AllUsers.values());
  users.sort((o1, o2) -> strategy.compare(o1.getId(), o2.getId()));
  return users;
}
origin: JetBrains/ideavim

@NotNull
public List<Mark> getMarks(@NotNull Editor editor) {
 HashSet<Mark> res = new HashSet<>();
 final FileMarks<Character, Mark> marks = getFileMarks(editor.getDocument());
 if (marks != null) {
  res.addAll(marks.values());
 }
 res.addAll(globalMarks.values());
 ArrayList<Mark> list = new ArrayList<>(res);
 list.sort(new Mark.KeySorter<>());
 return list;
}
origin: cbeust/testng

@SuppressWarnings("unchecked")
private void addAllTestResults(Set<ITestResult> testResults, IResultMap resultMap) {
 if (resultMap != null) {
  // Sort the results chronologically before adding them
  List<ITestResult> allResults = new ArrayList<>(resultMap.getAllResults());
  new ArrayList(allResults)
    .sort(
      (Comparator<ITestResult>)
        (o1, o2) -> (int) (o1.getStartMillis() - o2.getStartMillis()));
  testResults.addAll(allResults);
 }
}
origin: spring-projects/spring-framework

methods.sort((m1, m2) -> {
  int m1pl = m1.getParameterCount();
  int m2pl = m2.getParameterCount();
origin: neo4j/neo4j

out.sort( Comparator.comparing( a -> a.signature().name().toString() ) );
return out;
origin: neo4j/neo4j

out.sort( Comparator.comparing( a -> a.signature().name().toString() ) );
return out;
origin: neo4j/neo4j

out.sort( Comparator.comparing( a -> a.signature().name().toString() ) );
return out;
origin: gocd/gocd

  public List<JobInstanceModel> jobInstanceModelFor(JobInstances jobInstances) {
    ArrayList<JobInstanceModel> models = new ArrayList<>();
    for (JobInstance jobInstance : jobInstances) {
      AgentInstance agentInstance = jobInstance.isAssignedToAgent() ? agentService.findAgentAndRefreshStatus(jobInstance.getAgentUuid()) : null;
      JobInstanceModel model;
      if (null != agentInstance && !agentInstance.isNullAgent()) {
        model = new JobInstanceModel(jobInstance, jobDurationStrategy, agentInstance);
      } else if (jobInstance.getAgentUuid() != null) {
        Agent agent = agentService.findAgentObjectByUuid(jobInstance.getAgentUuid());
        model = new JobInstanceModel(jobInstance, jobDurationStrategy, agent);
      } else {
        model = new JobInstanceModel(jobInstance, jobDurationStrategy);
      }
      models.add(model);
    }
    models.sort(JobInstanceModel.JOB_MODEL_COMPARATOR);
    return models;
  }
}
origin: prestodb/presto

list.sort(Integer::compare);
assertEquals(list, ImmutableList.of(1, 2, 3, 4, 5));
assertTrue(queue.isFinished());
java.utilArrayListsort

Popular methods of ArrayList

  • <init>
  • add
  • size
    Returns the number of elements in this ArrayList.
  • get
    Returns the element at the specified position in this list.
  • toArray
    Returns an array containing all of the elements in this list in proper sequence (from first to last
  • addAll
    Adds the objects in the specified collection to this ArrayList.
  • remove
    Removes the first occurrence of the specified element from this list, if it is present. If the list
  • clear
    Removes all elements from this ArrayList, leaving it empty.
  • isEmpty
    Returns true if this list contains no elements.
  • iterator
    Returns an iterator over the elements in this list in proper sequence.The returned iterator is fail-
  • contains
    Searches this ArrayList for the specified object.
  • set
    Replaces the element at the specified position in this list with the specified element.
  • contains,
  • set,
  • indexOf,
  • clone,
  • subList,
  • stream,
  • ensureCapacity,
  • trimToSize,
  • removeAll,
  • toString

Popular in Java

  • Start an intent from android
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getExternalFilesDir (Context)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Best IntelliJ plugins
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