简体   繁体   English

如果您有一个字符串数组,以最快的顺序对该数组排序的最快方法是什么?

[英]If you had an array of Strings, what is the quickest way to sort this array in ascending order?

如果您有一个字符串数组,以最快的顺序对该数组排序的最快方法是什么?

See java.util.Arrays.sort(Object[]) 参见java.util.Arrays.sort(Object [])

import java.util.*;
Arrays.sort(stringarray)

Arrays.sort() for now. Arrays.sort()现在。

Also I heard that Josh Bloch is working on a much faster sort algorithm than the current mergesort. 我还听说Josh Bloch正在开发一种比当前mergesort更快的排序算法。 (I can't remember where, maybe in this interview . The new algorithm will perform better for partially sorted arrays and originates from a Python? sort implementation). (我不记得在哪儿了,也许在这次采访中 。新算法对于部分排序的数组表现更好,并且起源于Python?sort实现)。 Also see this question. 另请参阅问题。

String[] Mystring = {"cat","lion", "dog", "mouse"};
Arrays.sort(Mystring);

Sorting Arrays 排序数组

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM