队列排序 [英] Queue ordering

查看:33
本文介绍了队列排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目数组,排序后最旧的项目在数组中排在第一位.

I have an array of items, sorted so that the oldest item is first in the array.

我想从数组中加载一个队列,这样当我弹出队列中的项目时,最旧的项目首先出现.

I want to load a queue from the array, such that when I pop the items on the queue the oldest item comes first.

我该怎么做?

推荐答案

使用 LINQ to Objects...

Use LINQ to Objects...

var q = new Queue<T>(array.OrderBy(d => d.date));

操作,错误的方式.

这篇关于队列排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆