本文整理汇总了C#中IList.OrderBy方法的典型用法代码示例。如果您正苦于以下问题:C# IList.OrderBy方法的具体用法?C# IList.OrderBy怎么用?C# IList.OrderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IList
的用法示例。
在下文中一共展示了IList.OrderBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainSlow
internal static void MainSlow()
{
// Sets the Console to read from string
//Console.SetIn(new StringReader(Test001));
int n = int.Parse(Console.ReadLine());
frames = new List<int[]>(n);
perm = new int[n][];
used = new bool[n];
for (int i = 0; i < n; i++)
{
var frame = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
if (frame.Length != 2)
{
throw new ArgumentException("Frames must have two dimensions!");
}
frames.Add(frame);
}
frames = frames.OrderBy(f => f[0]).ThenBy(f => f[1]).ToList();
Permutate(0, n);
Console.WriteLine(count);
Console.WriteLine(string.Join(Environment.NewLine, allPerms.OrderBy(f => f)));
}
示例2: VisaData
public void VisaData(IList<AktivPeriod> perioder)
{
panel1.Controls.Clear();
double pixlarPerDygn = 1000;// (double)panel1.Width;
var förstaTimme = perioder.OrderBy(o => o.Starttid.Hour).FirstOrDefault().Starttid.Hour;
var sistaTimme = perioder.OrderBy(o => o.Starttid.Hour).LastOrDefault().Starttid.Hour;
var daghöjd = 30;
var marginal = 10;
var vänsterMarginal = 120;
var minutlängd = (pixlarPerDygn - vänsterMarginal) / (sistaTimme - förstaTimme) / 60; // pixlarPerDygn / 24 / 60;
var position = 0;
for (int timme = förstaTimme; timme <= sistaTimme; timme++)
{
var timstreck = new TimMarkering(timme);
timstreck.Top = 0;
timstreck.Left = (int)(position * minutlängd * 60) + vänsterMarginal;
panel1.Controls.Add(timstreck);
position++;
}
var y = marginal + daghöjd;
foreach (var period in perioder.OrderByDescending(o => o.Starttid).GroupBy(o => o.Starttid.Date).Select(o =>
new
{
Datum = o.Key,
Perioder = o
}))
{
var daglabel = new Label();
daglabel.Top = y;
daglabel.Left = marginal;
daglabel.Text = period.Datum.ToString("dddd, d MMM");
panel1.Controls.Add(daglabel);
foreach (var item in period.Perioder)
{
var aktivitet = new Aktivitetsmarkering(item);
aktivitet.BackColor = System.Drawing.Color.Blue;
aktivitet.Top = y;
aktivitet.Height = daghöjd;
aktivitet.Width = (int)(minutlängd * item.Tidsmängd.TotalMinutes);
if (aktivitet.Width == 0) aktivitet.Width = 1;
aktivitet.Left = (int)(item.Starttid.Subtract(period.Datum).TotalMinutes * minutlängd) + vänsterMarginal - (int)(förstaTimme * 60 * minutlängd);
panel1.Controls.Add(aktivitet);
}
y += daghöjd + marginal;
}
}
示例3: Sort
/// <summary>
/// Sorts the object collection by object Type, then by name of object.
/// This makes for an easy compare of two different memory snapshots
/// </summary>
/// <returns></returns>
public static IList<Object> Sort(IList<Object> unSorted)
{
if (unSorted == null)
return null;
IList<Object> sorted = unSorted.OrderBy(x => x.GetType().ToString()).ThenBy(x => x.name).ToList();
return sorted;
}
示例4: GuardarAsignaciones
public void GuardarAsignaciones(IList<int> ordenesVenta, IList<Usuario> asistentes)
{
try
{
var transactionOptions = new TransactionOptions { IsolationLevel = IsolationLevel.ReadUncommitted };
using (var transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
{
foreach (var idOrdenVenta in ordenesVenta)
{
var ordenVenta = _orderVentaDA.ObtenerPorID(idOrdenVenta);
var asistenteConMenorCarga = asistentes.OrderBy(p => p.CantidadOV).FirstOrDefault();
if (asistenteConMenorCarga != null)
{
asistenteConMenorCarga.CantidadOV++;
ordenVenta.Estado = Constantes.EstadoOrdenVenta.Asignado;
ordenVenta.AsistentePlaneamiento = asistenteConMenorCarga;
_orderVentaDA.AsignarAsistentePlaneamiento(ordenVenta);
}
}
transactionScope.Complete();
}
}
catch (Exception ex)
{
throw ThrowException(ex, MethodBase.GetCurrentMethod().Name);
}
}
示例5: Export
/// <summary>
/// Exports the provided questions in CSV format: category,question,answer
/// </summary>
/// <param name="questions"></param>
/// <returns></returns>
public static string Export(IList<Question> questions)
{
StringBuilder builder = new StringBuilder();
foreach (Question question in questions.OrderBy(q => q.Category.Name))
{
#if LOGGING
builder.AppendLine(string.Format("{0},{1},{2},{3}",
question.Category.Name.Replace(",", "~"),
question.Title.Replace(",", "~"),
question.Answer.Replace(",", "~"),
question.NextAskOn.ToShortDateString())
);
#else
builder.AppendLine(string.Format("{0},{1},{2}",
question.Category.Name.Replace(",","~"),
question.Title.Replace(",","~"),
question.Answer.Replace(",","~"))
);
#endif
}
return builder.ToString();
}
示例6: Page_Init
protected void Page_Init(object sender, EventArgs e)
{
Drugs = Lib.Data.Drug.FindAll();
SelectedDrugs = Lib.Systems.Lists.GetMyDrugs();
AvailableDrugs = new List<Lib.Data.Drug>();
foreach (var d in Drugs)
{
bool found = false;
for (int i = 0; i < SelectedDrugs.Count; i++)
{
if (d.ID.Value == SelectedDrugs[i].ID.Value)
{
found = true;
break;
}
}
if (found)
continue;
AvailableDrugs.Add(d);
}
SelectedDrugs = SelectedDrugs.OrderBy(l => l.GenericName).ToList();
AvailableDrugs = AvailableDrugs.OrderBy(l => l.GenericName).ToList();
Eocs = _complianceSvc.GetEocs().ToList();
}
示例7: CompareExecutionTime
/// <summary>
/// Benchmarks and compares the execution time stats of the given algorithms.
/// </summary>
/// <param name="numberOfIterations">The number of iterations to run.</param>
/// <param name="reportIndividualIterations">
/// <para>If set to <c>true</c>, reports individual iteration stats; if <c>false</c>, reports average iteration stats.</para>
/// <para>If the algorithm runs really fast, the floating point calculations will come out to zero, so you will want to set this to <c>false</c>.</para>
/// </param>
/// <param name="algorithms">The algorithms to compare.</param>
/// <returns>The list of algorithms, sorted from fastest to slowest, with their <see cref="Algorithm.ExecutionTime"/> property set.</returns>
public static IList<Algorithm> CompareExecutionTime(int numberOfIterations, bool reportIndividualIterations, IList<Algorithm> algorithms)
{
if (algorithms == null || !algorithms.Any())
{
throw new ArgumentNullException("algorithms");
}
foreach (Algorithm algorithm in algorithms)
{
("Running " + algorithm.Name).Dump();
algorithm.BenchmarkAndCacheExecutionTime(numberOfIterations, reportIndividualIterations);
"\tDone".Dump();
}
"".Dump();
("Total iterations: " + numberOfIterations.ToString("n0")).Dump();
"".Dump();
algorithms = algorithms.OrderBy(algorithm => algorithm.ExecutionTime.Average).ToList();
for (int i = 0; i < algorithms.Count; i++)
{
DumpAlgorithmStats(algorithms[i], i + 1 < algorithms.Count ? algorithms[i + 1] : null, reportIndividualIterations);
}
return algorithms;
}
示例8: GetDiscountPrices
private IList<IPriceValue> GetDiscountPrices(IList<IPriceValue> prices, MarketId marketId, Currency currency)
{
currency = GetCurrency(currency, marketId);
var priceValues = new List<IPriceValue>();
_promotionHelper.Reset();
foreach (var entry in GetEntries(prices))
{
var price = prices
.OrderBy(x => x.UnitPrice.Amount)
.FirstOrDefault(x => x.CatalogKey.CatalogEntryCode.Equals(entry.Code) &&
x.UnitPrice.Currency.Equals(currency));
if (price == null)
{
continue;
}
priceValues.Add(_promotionEntryService.GetDiscountPrice(
price, entry, currency, _promotionHelper));
}
return priceValues;
}
示例9: TryGetNext
/// <summary>
/// Returns the next machine to schedule.
/// </summary>
/// <param name="next">Next</param>
/// <param name="choices">Choices</param>
/// <param name="current">Curent</param>
/// <returns>Boolean</returns>
public virtual bool TryGetNext(out MachineInfo next, IList<MachineInfo> choices, MachineInfo current)
{
var machines = choices.OrderBy(mi => mi.Machine.Id.Value).ToList();
var currentMachineIdx = machines.IndexOf(current);
var orderedMachines = machines.GetRange(currentMachineIdx, machines.Count - currentMachineIdx);
if (currentMachineIdx != 0)
{
orderedMachines.AddRange(machines.GetRange(0, currentMachineIdx));
}
var availableMachines = orderedMachines.Where(
mi => mi.IsEnabled && !mi.IsBlocked && !mi.IsWaiting).ToList();
if (availableMachines.Count == 0)
{
next = null;
return false;
}
int idx = 0;
while (this.RemainingDelays.Count > 0 && this.ExploredSteps == this.RemainingDelays[0])
{
idx = (idx + 1) % availableMachines.Count;
this.RemainingDelays.RemoveAt(0);
IO.PrintLine("<DelayLog> Inserted delay, '{0}' remaining.", this.RemainingDelays.Count);
}
next = availableMachines[idx];
this.ExploredSteps++;
return true;
}
示例10: ZapperProcessor
public ZapperProcessor(FileZapperSettings settings = null, IList<IZapperPhase> phases = null)
{
_log.Info("Initializing");
ZapperFiles = new ConcurrentDictionary<string, ZapperFile>();
ZapperFilesDeleted = new ConcurrentDictionary<string, ZapperFileDeleted>();
if (settings == null)
{
settings = new FileZapperSettings();
settings.Load();
}
Settings = settings;
if (phases != null)
{
foreach (var phase in phases) { phase.ZapperProcessor = this; }
_phases = phases.OrderBy(x => x.PhaseOrder);
}
else
{
List<IZapperPhase> allphases = new List<IZapperPhase>();
allphases.Add(new PhaseCleanup { PhaseOrder = 1, ZapperProcessor = this, IsInitialPhase = true });
allphases.Add(new PhaseParseFilesystem { PhaseOrder = 2, ZapperProcessor = this });
allphases.Add(new PhaseCalculateSamples { PhaseOrder = 3, ZapperProcessor = this });
allphases.Add(new PhaseCalculateHashes { PhaseOrder = 4, ZapperProcessor = this });
allphases.Add(new PhaseRemoveDuplicates { PhaseOrder = 5, ZapperProcessor = this });
_phases = allphases.OrderBy(x => x.PhaseOrder);
}
}
示例11: frmRefundTypeMappings
public frmRefundTypeMappings(IList<RefundTypeMappingDTO> refundMappingTypeDTOs)
{
InitializeComponent();
checkBoxIssueRefundCheck.DataBindings.Add(new Binding("Checked", refundTypeMappingDTOBindingSource, "IssueCheck", true, DataSourceUpdateMode.OnPropertyChanged));
checkBoxEnabled.DataBindings.Add(new Binding("Checked", refundTypeMappingDTOBindingSource, "Enabled", true, DataSourceUpdateMode.OnPropertyChanged));
checkBoxIssueRefundCheck.DataBindings.Add(new Binding("Enabled", refundTypeMappingDTOBindingSource, "Enabled", true, DataSourceUpdateMode.OnPropertyChanged));
comboBoxCheckRecipient.DataBindings.Add(new Binding("Enabled", refundTypeMappingDTOBindingSource, "EnableCheckField", true, DataSourceUpdateMode.OnPropertyChanged));
comboBoxCheckRecipient.DataBindings.Add(new Binding("SelectedItem", refundTypeMappingDTOBindingSource, "RefundCheckRecipient"));
comboBoxQBFrom.DataBindings.Add(new Binding("Enabled", refundTypeMappingDTOBindingSource, "EnableFromField", true, DataSourceUpdateMode.OnPropertyChanged));
comboBoxQBPaymentType.DataBindings.Add(new Binding("Enabled", refundTypeMappingDTOBindingSource, "EnableQuickbooksPayTypeField", true, DataSourceUpdateMode.OnPropertyChanged));
comboBoxQBIncomeAccount.DataBindings.Add(new Binding("Enabled", refundTypeMappingDTOBindingSource, "Enabled", true, DataSourceUpdateMode.OnPropertyChanged));
comboBoxRefundBankAccount.DataBindings.Add(new Binding("Enabled", refundTypeMappingDTOBindingSource, "EnableBankAccountField", true, DataSourceUpdateMode.OnPropertyChanged));
comboBoxCheckRecipient.DataSource = Enum.GetValues(typeof(RefundCheckRecipient));
Configuration configuration = UserSettings.getInstance().Configuration;
quickbooksPaytypeBindingSource.DataSource = configuration.QuickbooksPaytypes;
quickbooksCustomerBindingSource.DataSource = configuration.QuickbooksCustomers;
quickbooksIncomeAccountBindingSource.DataSource = configuration.QuickbooksIncomeAccounts;
quickbooksBankAccountBindingSource.DataSource = configuration.QuickbooksBankAccounts;
refundTypeMappingDTOBindingSource.DataSource = refundMappingTypeDTOs.OrderBy(x => x.EaglesoftAdjustment);
}
示例12: ProductViewModel
public ProductViewModel(Product product, IList<Category> categories)
: this()
{
this.ProductId = product.Id;
this.ProductGuid = product.Guid;
this.Code = product.Code;
this.Title = product.Title;
this.Description = product.Description;
this.Keywords = product.Keywords;
this.Cost = product.Cost;
this.Type = product.Type;
this.IsFeatured = product.IsFeatured;
this.ImageUrls = product.Images.Select(o => new ProductImageViewModel(o)).ToList();
foreach (Category category in categories.OrderBy(o => o.DisplayName))
{
CategoryViewModel categoryViewModel = new CategoryViewModel(category);
categoryViewModel.Selected = product.Categories.Any(o => o.Id == category.Id);
foreach(var child in category.Children)
{
categoryViewModel.Children.First(o => o.Id == child.Id).Selected = product.Categories.Any(o => o.Id == category.Id && o.Children.Any(x => x.Id == child.Id));
}
this.Categories.Add(categoryViewModel);
}
}
示例13: AllAnalysesEqual
/// <summary>
/// Bir kelimenin çözümleri ile aranan çözümlerin aynı sayıda ve bire bir aynı
/// olup olmadığını kontrol eder. Aranan çözümlerin hangi sırada verildiği önemli değildir.
/// </summary>
/// <param name="token">kelime</param>
/// <param name="expectedAnalyses">aranan ve olması gereken çözümlerin tamamı</param>
public static void AllAnalysesEqual(string token, IList<string> expectedAnalyses)
{
IList<Word> words = Analyzer.Analyze(token);
IList<string> actualAnalyses = words.Select(word => word.Analysis).ToList();
bool equalIgnoreOrder = actualAnalyses.OrderBy(t => t).SequenceEqual(expectedAnalyses.OrderBy(t => t));
Assert.True(equalIgnoreOrder);
}
示例14: AssertEquals
void AssertEquals(IList<IList<int>> firstList, IList<IList<int>> secondList)
{
Assert.AreEqual(firstList.Count(), secondList.Count());
firstList = firstList
.OrderBy(list => list[0])
.ThenBy(list => list[1])
.ThenBy(list => list[2])
.ToList();
secondList = secondList
.OrderBy(list => list[0])
.ThenBy(list => list[1])
.ThenBy(list => list[2])
.ToList();
Assert.IsTrue(firstList
.Zip(secondList
, (firstSubList, secondeSubList) =>
firstSubList
.Zip(secondeSubList
, (first, second) =>
first == second)
.All(item => item))
.All(item => item)); ;
}
示例15: Init
public void Init(dynamic pedal, IList<ToolkitKnob> knobs)
{
var sortedKnobs = knobs.OrderBy(k => k.Index).ToList();
tableLayoutPanel.RowCount = knobs.Count;
for (var i = 0; i < sortedKnobs.Count; i++)
{
var knob = sortedKnobs[i];
var label = new Label();
tableLayoutPanel.Controls.Add(label, 0, i);
if (knob.Name != null)
{
var name = knob.Name;
var niceName = nameParser.Match(name);
if(niceName.Groups.Count > 1) {
name = niceName.Groups[1].Value;
}
label.Text = name;
}
label.Anchor = AnchorStyles.Left;
var numericControl = new NumericUpDownFixed();
tableLayoutPanel.Controls.Add(numericControl, 1, i);
numericControl.DecimalPlaces = 2;
numericControl.Minimum = (decimal)knob.MinValue;
numericControl.Maximum = (decimal)knob.MaxValue;
numericControl.Increment = (decimal)knob.ValueStep;
numericControl.Value = Math.Min((decimal)pedal.KnobValues[knob.Key], numericControl.Maximum);
numericControl.ValueChanged += (obj, args) =>
pedal.KnobValues[knob.Key] = (float)Math.Min(numericControl.Value, numericControl.Maximum);
}
}