当前位置: 首页>>代码示例>>Java>>正文


Java Collections.sort方法代码示例

本文整理汇总了Java中java.util.Collections.sort方法的典型用法代码示例。如果您正苦于以下问题:Java Collections.sort方法的具体用法?Java Collections.sort怎么用?Java Collections.sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Collections的用法示例。


在下文中一共展示了Collections.sort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: WeekLessonDiaLogItemAdapter

import java.util.Collections; //导入方法依赖的package包/类
public WeekLessonDiaLogItemAdapter(@Nonnull Context context, @Nonnull List<WeekLessonDialogItem> list, int text_color, int bg_color) {
    super(context, null);
    mIsExpandPosList = new ArrayList<>();
    Collections.sort(list, weekLessonDialogItemComparator);
    mListData.addAll(list);

    for (int i = 0; i < mListData.size(); i++) {
        mIsExpandPosList.add(false);
    }

    try {
        mRepeatList = mDbHelper.getRepeatList();
    } catch (NullObjectException e) {
        Log.d(TAG, e.toString());
    }

    mTextColor = text_color;
    mBgColor = bg_color;

    Resources resources = mContext.getResources();
    mStatus_New = resources.getString(R.string.status_new);
    mStatus_Unsaved = resources.getString(R.string.status_change);
}
 
开发者ID:nhocga1995s,项目名称:MyCalendar,代码行数:24,代码来源:WeekLessonDiaLogItemAdapter.java

示例2: toggleFileTree

import java.util.Collections; //导入方法依赖的package包/类
private void toggleFileTree(File file){
    //路径名
    mTvPath.setText(getString(R.string.nb_file_path,file.getPath()));
    //获取数据
    File[] files = file.listFiles(new SimpleFileFilter());
    //转换成List
    List<File> rootFiles = Arrays.asList(files);
    //排序
    Collections.sort(rootFiles,new FileComparator());
    //加入
    mAdapter.refreshItems(rootFiles);
    //反馈
    if (mListener != null){
        mListener.onCategoryChanged();
    }
}
 
开发者ID:newbiechen1024,项目名称:NovelReader,代码行数:17,代码来源:FileCategoryFragment.java

示例3: onActualMessagePeerMessageReceived

import java.util.Collections; //导入方法依赖的package包/类
private void onActualMessagePeerMessageReceived(int accountId, int peerId, int unreadCount, Message message) {
    if (accountId != this.dialogsOwnerId) {
        return;
    }

    int index = indexOf(this.dialogs, peerId);

    if (index != -1) {
        Dialog dialog = this.dialogs.get(index);

        dialog.setMessage(message)
                .setUnreadCount(unreadCount)
                .setLastMessageId(message.getId());

        if (dialog.isChat()) {
            dialog.setInterlocutor(message.getSender());
        }

        Collections.sort(this.dialogs, COMPARATOR);
    }

    safeNotifyDataSetChanged();
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:24,代码来源:DialogsPresenter.java

示例4: getCountries

import java.util.Collections; //导入方法依赖的package包/类
public static List<LocationDto> getCountries(LocationDto area) throws ExternalServiceException {
    try {
        List<LocationDto> countries = new ArrayList<LocationDto>();
        if (area == null) {
            return Collections.emptyList();
        }
        for (LocationDto loc : area.getChildren()) {
            if (!isAlive(loc)) {
                continue;
            }
            LocationType type = getLocationType(loc);
            if (type != null && type == LocationType.COUNTRY) {
                countries.add(loc);
            }
        }
        Collections.sort(countries, new LocationComparator());
        return countries;
    } catch (Exception e) {
        throw ExceptionUtils.getExternalServiceException(e);
    }
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:22,代码来源:LocationUtil.java

示例5: toSort

import java.util.Collections; //导入方法依赖的package包/类
/**
 * 简单的单维比较排序(正序)
 * 
 * @author      ZhengWei(HY)
 * @createDate  2015-12-10
 * @version     v1.0
 *
 * @param i_Values
 * @return
 */
@SafeVarargs
public final static <T extends Comparable<? super T>> List<T> toSort(T ... i_Values)
{
    if ( Help.isNull(i_Values) )
    {
        return new ArrayList<T>(0);
    }
    
    List<T> v_Values = new ArrayList<T>(i_Values.length);
    
    for (T v_Item : i_Values)
    {
        v_Values.add(v_Item);
    }
    
    Collections.sort(v_Values);
    
    return v_Values;
}
 
开发者ID:HY-ZhengWei,项目名称:hy.common.base,代码行数:30,代码来源:Help.java

示例6: orderCollection

import java.util.Collections; //导入方法依赖的package包/类
/**
 * Ordernar uma lista
 * @param collecao 
 * @param orderMode 
 */
public static void orderCollection (List collecao, OrederBy orderMode)
{
    Float f;
    Integer i;
    if (orderMode == OrederBy.ASC)
        Collections.sort(collecao);
    else
    {
        Comparator c = (Comparator) (Object o1, Object o2) -> 
        {
            try
            {
                Comparable co1 = (Comparable) o1;
                if (o1.getClass().equals(o2.getClass()))
                {
                    return  co1.compareTo(o2) * -1;
                }
            }catch(Exception ex) {}
            return 0;
        };
        Collections.sort(collecao, c); 
    }
}
 
开发者ID:JIGAsoftSTP,项目名称:NICON,代码行数:29,代码来源:OperacaoString.java

示例7: sortCraftManager

import java.util.Collections; //导入方法依赖的package包/类
public static void sortCraftManager()
{
    bake();
    FMLLog.fine("Sorting recipes");
    warned.clear();
    Collections.sort(CraftingManager.getInstance().getRecipeList(), INSTANCE);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:8,代码来源:RecipeSorter.java

示例8: dumpRandomSentences

import java.util.Collections; //导入方法依赖的package包/类
/**
 * Dump a set of random sentences that fit this grammar
 * 
 * @param count
 *            dumps no more than this. May dump less than this depending
 *            upon the number of uniqe sentences in the grammar.
 */
public void dumpRandomSentences(int count) {
	Set<String> set = new HashSet<String>();
	for (int i = 0; i < count; i++) {
		String s = getRandomSentence();
		if (!set.contains(s)) {
			set.add(s);
		}
	}
	List<String> sampleList = new ArrayList<String>(set);
	Collections.sort(sampleList);

	for (String sentence : sampleList) {
		System.out.println(sentence);
	}
}
 
开发者ID:CognitiveModeling,项目名称:BrainControl,代码行数:23,代码来源:GrammarDump.java

示例9: setWidgets

import java.util.Collections; //导入方法依赖的package包/类
public void setWidgets(MultiHashMap<PackageItemInfo, WidgetItem> widgets) {
    mEntries.clear();
    WidgetItemComparator widgetComparator = new WidgetItemComparator();

    for (Map.Entry<PackageItemInfo, ArrayList<WidgetItem>> entry : widgets.entrySet()) {
        WidgetListRowEntry row = new WidgetListRowEntry(entry.getKey(), entry.getValue());
        row.titleSectionName = mIndexer.computeSectionName(row.pkgItem.title);
        Collections.sort(row.widgets, widgetComparator);
        mEntries.add(row);
    }

    Collections.sort(mEntries, new WidgetListRowEntryComparator());
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:14,代码来源:WidgetsListAdapter.java

示例10: toSetOf

import java.util.Collections; //导入方法依赖的package包/类
private static byte[] toSetOf(Collection<?> values, Asn1Type elementType)
        throws Asn1EncodingException {
    List<byte[]> serializedValues = new ArrayList<>(values.size());
    for (Object value : values) {
        serializedValues.add(JavaToDerConverter.toDer(value, elementType, null));
    }
    if (serializedValues.size() > 1) {
        Collections.sort(serializedValues, ByteArrayLexicographicComparator.INSTANCE);
    }
    return createTag(
            BerEncoding.TAG_CLASS_UNIVERSAL, true, BerEncoding.TAG_NUMBER_SET,
            serializedValues.toArray(new byte[0][]));
}
 
开发者ID:F8LEFT,项目名称:FApkSigner,代码行数:14,代码来源:Asn1DerEncoder.java

示例11: updateOrder

import java.util.Collections; //导入方法依赖的package包/类
public void updateOrder() {
    synchronized (mAddedAppItems) {
        Collections.sort(mAddedAppItems, new AppItem.IndexComparator());
    }
    notifyListener();
    mHandler.obtainMessage(MSG_SAVE_ORDER).sendToTarget();
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:8,代码来源:AppManager.java

示例12: processResult

import java.util.Collections; //导入方法依赖的package包/类
public void processResult(int rc, String path, Object ctx,
        List<String> children, Stat stat)
{
    this.children =
        (children == null ? new ArrayList<String>() : children);
    Collections.sort(this.children);
    super.processResult(Code.get(rc), path, ctx);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:9,代码来源:AsyncOps.java

示例13: getHardwareProperties

import java.util.Collections; //导入方法依赖的package包/类
/**
 * Returns the hardware properties defined in
 * {@link AvdManager#HARDWARE_INI} as a {@link Map}.
 *
 * This is intended to be dumped in the config.ini and already contains
 * the device name, manufacturer and device hash.
 *
 * @param d The {@link Device} from which to derive the hardware properties.
 * @return A {@link Map} of hardware properties.
 */
@NonNull
public static Map<String, String> getHardwareProperties(@NonNull Device d) {
    Map<String, String> props = getHardwareProperties(d.getDefaultState());
    for (State s : d.getAllStates()) {
        if (s.getKeyState().equals(KeyboardState.HIDDEN)) {
            props.put("hw.keyboard.lid", getBooleanVal(true));
        }
    }

    HashFunction md5 = Hashing.md5();
    Hasher hasher = md5.newHasher();

    ArrayList<String> keys = new ArrayList<String>(props.keySet());
    Collections.sort(keys);
    for (String key : keys) {
        if (key != null) {
            hasher.putString(key, Charsets.UTF_8);
            String value = props.get(key);
            hasher.putString(value == null ? "null" : value, Charsets.UTF_8);
        }
    }
    // store the hash method for potential future compatibility
    String hash = "MD5:" + hasher.hash().toString();
    props.put(AvdManager.AVD_INI_DEVICE_HASH_V2, hash);
    props.remove(AvdManager.AVD_INI_DEVICE_HASH_V1);

    props.put(AvdManager.AVD_INI_DEVICE_NAME, d.getId());
    props.put(AvdManager.AVD_INI_DEVICE_MANUFACTURER, d.getManufacturer());
    return props;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:41,代码来源:DeviceManager.java

示例14: testInnerClassSort

import java.util.Collections; //导入方法依赖的package包/类
public void testInnerClassSort()
{
  Comparator<? super Coordinate> coordSorter = new Comp();
  List<? extends Coordinate>  points = (List)makeSampleList();
  Collections.sort( points, coordSorter );
  assertEquals( makeSampleList_Sorted(), points );
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:8,代码来源:StructuralTypeTest.java

示例15: calculateMin

import java.util.Collections; //导入方法依赖的package包/类
private int calculateMin(List<Integer> items) {
    Collections.sort(items);
    return (items.size() > 0) ? items.get(0) : 0;
}
 
开发者ID:adr,项目名称:eadlsync,代码行数:5,代码来源:Statistic.java


注:本文中的java.util.Collections.sort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。