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


C# IEnumerable.OrderByDescending方法代码示例

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


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

示例1: CreateList

        public async Task<IEnumerable<ParkingLot>> CreateList(IEnumerable<ParkingLot> items)
        {
            var mainVm = ServiceLocator.Current.GetInstance<MainViewModel>();
            var filter = mainVm.ParkingLotFilterMode;
            var orderAsc = mainVm.ParkingLotFilterAscending;
            var alphabeticalSortingFunc = new Func<ParkingLot, string>(x => x.Name);
            switch (filter)
            {
                case ParkingLotFilterMode.Alphabetically:
                    return orderAsc ? items.OrderBy(alphabeticalSortingFunc) : items.OrderByDescending(alphabeticalSortingFunc);
                case ParkingLotFilterMode.Availability:
                    var availabilitySortingFunc = new Func<ParkingLot, double>(x =>
                    {
                        if (x.TotalLots == 0)
                        {
                            return 2; //they're always last of the list
                        }
                        return 1 - ((double) x.FreeLots / (double)x.TotalLots); //something between 0 and 1
                    });
                    return orderAsc ? items.OrderBy(availabilitySortingFunc).ThenBy(alphabeticalSortingFunc) : items.OrderByDescending(availabilitySortingFunc).ThenBy(alphabeticalSortingFunc);
                case ParkingLotFilterMode.Distance:
                    var userPos = await ServiceLocator.Current.GetInstance<GeolocationService>().GetUserLocation();
                    if (userPos == null)
                    {
                        mainVm.ParkingLotFilterMode = ParkingLotFilterMode.Alphabetically;
                        return await CreateList(items);
                    }

                    var distanceSortingFunc = new Func<ParkingLot, double>(x => x?.Coordinates?.Point == null ? double.MaxValue : userPos.Coordinate.Point.GetDistanceTo(x.Coordinates.Point));
                    return orderAsc ? items.OrderBy(distanceSortingFunc).ThenBy(alphabeticalSortingFunc) : items.OrderByDescending(distanceSortingFunc).ThenBy(alphabeticalSortingFunc);
                default:
                    return orderAsc ? items.OrderBy(alphabeticalSortingFunc) : items.OrderByDescending(alphabeticalSortingFunc);
            }
        }
开发者ID:sibbl,项目名称:ParkenDD,代码行数:34,代码来源:ParkingLotListFilterService.cs

示例2: CreateGroupedItems

		private IEnumerable<IGrouping<string, RepositoryDetailedModel>> CreateGroupedItems(IEnumerable<RepositoryDetailedModel> model)
        {
            var order = Repositories.Filter.OrderBy;

            if (order == RepositoriesFilterModel.Order.LastUpdated)
            {
                var a = model.OrderByDescending(x => x.UtcLastUpdated).GroupBy(x => FilterGroup.IntegerCeilings.First(r => r > x.UtcLastUpdated.TotalDaysAgo()));
                a = Repositories.Filter.Ascending ? a.OrderBy(x => x.Key) : a.OrderByDescending(x => x.Key);
                return FilterGroup.CreateNumberedGroup(a, "Days Ago", "Updated");
            }
            if (order == RepositoriesFilterModel.Order.CreatedOn)
            {
                var a = model.OrderByDescending(x => x.UtcCreatedOn).GroupBy(x => FilterGroup.IntegerCeilings.First(r => r > x.UtcCreatedOn.TotalDaysAgo()));
                a = Repositories.Filter.Ascending ? a.OrderBy(x => x.Key) : a.OrderByDescending(x => x.Key);
                return FilterGroup.CreateNumberedGroup(a, "Days Ago", "Created");
            }
            if (order == RepositoriesFilterModel.Order.Owner)
            {
                var a = model.OrderBy(x => x.Name).GroupBy(x => x.Owner);
                a = Repositories.Filter.Ascending ? a.OrderBy(x => x.Key) : a.OrderByDescending(x => x.Key);
                return a.ToList();
            }

            return null;
        }
开发者ID:xNUTs,项目名称:CodeBucket,代码行数:25,代码来源:RepositoriesViewModel.cs

示例3: CheckSortOrder

 //Check the Sort Order to sort with corresponding column
 public void CheckSortOrder(string sortOrder, ref IEnumerable<Comment> comment)
 {
     switch (sortOrder)
     {
         case "Date_desc":
             comment = comment.OrderByDescending(u => u.PostedDate);
             break;
         case "PatientName":
             comment = comment.OrderBy(u => u.Patient.FullName);
             break;
         case "PatientName_desc":
             comment = comment.OrderByDescending(u => u.Patient.FullName);
             break;
         case "DoctorName":
             comment = comment.OrderBy(u => u.Doctor.FullName);
             break;
         case "DoctorName_desc":
             comment = comment.OrderByDescending(u => u.Doctor.FullName);
             break;
         case "Content":
             comment = comment.OrderBy(u => u.Content);
             break;
         case "Content_desc":
             comment = comment.OrderByDescending(u => u.Content);
             break;
         default:
             comment = comment.OrderBy(u => u.PostedDate);
             break;
     }
 }
开发者ID:palaniellappank,项目名称:online-medical-consultant-system,代码行数:31,代码来源:AdminCommentBusiness.cs

示例4: SortProducts

 IEnumerable<Product> SortProducts(IEnumerable<Product> products, string sortOrder)
 {
     switch (sortOrder)
     {
         case NAME:
             products = products.OrderByDescending(s => s.name);
             break;
         case MANUNAME:
             products = products.OrderBy(s => s.Manufacturer);
             break;
         case MFGDISCOUNT:
             products = products.OrderByDescending(s => s.Manufacturer.mfgDiscount);
             break;
         case PRICE:
             products = products.OrderByDescending(s => s.price);
             break;
         case VENDOR:
             products = products.OrderByDescending(s => s.vendor);
             break;
         default:
             products = products.OrderByDescending(s => s.productID);
             break;
     }
     return products;
 }
开发者ID:JayOwl,项目名称:Pagination-ASP-MySql,代码行数:25,代码来源:FoodRespository.cs

示例5: getList

        public IPagedList<Facility> getList(string sortOrder, string currentFilter, int? page, IEnumerable<Facility> data)
        {
            ViewBag.CurrentSort = sortOrder;
            ViewBag.Name = String.IsNullOrEmpty(sortOrder) ? "Name_desc" : "";
            ViewBag.IsFree = sortOrder == "IsFree" ? "IsFree_desc" : "IsFree";
            ViewBag.Enabled = sortOrder == "Enabled" ? "Enabled_desc" : "Enabled";
            ViewBag.SO_RateTypeId = sortOrder == "RateTypeId" ? "RateTypeId_desc" : "RateTypeId";
            ViewBag.Rate = sortOrder == "Rate" ? "Rate_desc" : "Rate";
            ViewBag.IsGST = sortOrder == "IsGST" ? "IsGST_desc" : "IsGST";
            switch (sortOrder)
            {
                case "Name_desc":
                    data = data.OrderByDescending(s => s.Name );
                    break;
                case "IsFree":
                    data = data.OrderBy(s => s.IsFree);
                    break;
                case "IsFree_desc":
                    data = data.OrderByDescending(s => s.IsFree);
                    break;
                case "Enabled":
                    data = data.OrderBy(s => s.Enabled);
                    break;
                case "Enabled_desc":
                    data = data.OrderByDescending(s => s.Enabled);
                    break;
                case "RateTypeId":
                    data = data.OrderBy(s => s.RateTypeId);
                    break;
                case "RateTypeId_desc":
                    data = data.OrderByDescending(s => s.RateTypeId);
                    break;
                case "Rate":
                    data = data.OrderBy(s => s.Rate);
                    break;
                case "Rate_desc":
                    data = data.OrderByDescending(s => s.Rate);
                    break;
                case "IsGST":
                    data = data.OrderBy(s => s.IsGST);
                    break;
                case "IsGST_desc":
                    data = data.OrderByDescending(s => s.IsGST);
                    break;
                case "":
                default:
                    data = data.OrderBy(s => s.Name);
                    break;
            }

            int pageSize = Configurations.PageSize(); 
            int pageNumber = (page ?? 1);
            return data.ToPagedList(pageNumber, pageSize);
        }
开发者ID:DureSameen,项目名称:RoomReservation2,代码行数:54,代码来源:FacilitiesController.cs

示例6: _ContentFeedViewModel

        public _ContentFeedViewModel(IEnumerable<Content> content, Guid? authorId, string groupUrl, int contentPerPage = 5)
        {
            AuthorId = authorId;
            GroupUrl = groupUrl;

            if (authorId.HasValue)
                content = content.OrderByDescending(x => x.IsUserAttached(authorId.Value));
            if (!string.IsNullOrEmpty(groupUrl))
                content = content.OrderByDescending(x => x.IsGroupAttached(groupUrl));

            FeedContent = new PaginationList<_ContentFeed_ContentViewModel, Content>(content, contentPerPage, x => new _ContentFeed_ContentViewModel(x));
        }
开发者ID:arbium,项目名称:democratia2,代码行数:12,代码来源:_ContentFeedViewModel.cs

示例7: _SortRowsByColumn

        private IEnumerable<DataGridViewRow> _SortRowsByColumn(IEnumerable<DataGridViewRow> rows)
        {
            var get_row_mod_name = new Func<DataGridViewRow, string>(row => ((GUIMod) row.Tag).Name);
            Func<DataGridViewRow, string> sort_fn;

            // XXX: There should be a better way to identify checkbox columns than hardcoding their indices here
            if (this.m_Configuration.SortByColumnIndex < 2)
            {
                sort_fn = new Func<DataGridViewRow, string>(row =>
                {
                    var cell = row.Cells[this.m_Configuration.SortByColumnIndex];
                    if (cell.ValueType == typeof (bool))
                    {
                        return (bool) cell.Value ? "a" : "b";
                    }
                    // It's a "-" cell so let it be ordered last
                    return "c";
                });
            }
            else
            {
                sort_fn =
                    new Func<DataGridViewRow, string>(
                        row => row.Cells[this.m_Configuration.SortByColumnIndex].Value.ToString());
            }
            // Update the column sort glyph
            this.ModList.Columns[this.m_Configuration.SortByColumnIndex].HeaderCell.SortGlyphDirection =
                this.m_Configuration.SortDescending ? SortOrder.Descending : SortOrder.Ascending;
            // The columns will be sorted by mod name in addition to whatever the current sorting column is
            if (this.m_Configuration.SortDescending)
            {
                return rows.OrderByDescending(sort_fn).ThenBy(get_row_mod_name);
            }
            return rows.OrderBy(sort_fn).ThenBy(get_row_mod_name);
        }
开发者ID:Rusk85,项目名称:CKAN,代码行数:35,代码来源:MainModList.cs

示例8: DownloadVideo

        private static void DownloadVideo(IEnumerable<VideoInfo> videoInfos)
        {
            /*
             * Select the first .mp4 video with 360p resolution
             */
            VideoInfo video = videoInfos
                .OrderByDescending(v => v.Resolution).First(info => info.VideoType == VideoType.Mp4);

            /*
             * If the video has a decrypted signature, decipher it
             */
            if(video.RequiresDecryption) {
                DownloadUrlResolver.DecryptDownloadUrl(video);
            }

            /*
             * Create the video downloader.
             * The first argument is the video to download.
             * The second argument is the path to save the video file.
             */
            var videoDownloader = new VideoDownloader(video,
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                RemoveIllegalPathCharacters(video.Title) + video.VideoExtension));

            // Register the ProgressChanged event and print the current progress
            videoDownloader.DownloadProgressChanged += (sender, args) => Console.WriteLine(args.ProgressPercentage);

            /*
             * Execute the video downloader.
             * For GUI applications note, that this method runs synchronously.
             */
            videoDownloader.Execute();
        }
开发者ID:Zyano,项目名称:YoutubeExtractor,代码行数:33,代码来源:Program.cs

示例9: BerechneWechselgeld

 public Wechselgeld BerechneWechselgeld(IEnumerable<Münze> verfügbareMünzen, Cents betrag)
 {
     var münzen = verfügbareMünzen.OrderByDescending(i => i).ToArray();
     var lösung = LöseRekursiv(münzen, 0, betrag);
     if (lösung == null) throw new Exception("keine Lösung gefunden");
     return lösung.Item2;
 }
开发者ID:CarstenKoenig,项目名称:CoinKata,代码行数:7,代码来源:CoinChanger_BruteForce.cs

示例10: PackageInfo

        IPackageInfo PackageInfo(IEnumerable<IPackageInfo> packageInfos)
        {
            if (Version != null)
                return packageInfos.OrderByDescending(x => x.Version).FirstOrDefault(x => x.Version.Major.Equals(Version.Major) && x.Version.Major.Equals(Version.Major));

            return packageInfos.Last();
        }
开发者ID:carcer,项目名称:openwrap,代码行数:7,代码来源:ViewWrapCommand.cs

示例11: MicroDataProcessor

 public MicroDataProcessor(IEnumerable<MicroDataEntry> microDataEntries)
 {
     if (microDataEntries != null)
     {
         _microDataEntries = microDataEntries.OrderByDescending(o => o.ContentType.GetValueOrDefault(Guid.Empty));
     }
 }
开发者ID:4-Roads,项目名称:FourRoads.TelligentCommunity,代码行数:7,代码来源:MicroDataProcessor.cs

示例12: BerechneWechselgeld

 public Wechselgeld BerechneWechselgeld(IEnumerable<Münze> verfügbareMünzen, Cents betrag)
 {
     var münzen = verfügbareMünzen.OrderByDescending(i => i);
     var initial = Tuple.Create((Wechselgeld) new AnzahlMünzePaar[] {}, betrag);
     var gewählteMünzen = münzen.Aggregate(initial, AusgabeUndRestbetragFürMünze);
     return gewählteMünzen.Item1;
 }
开发者ID:CarstenKoenig,项目名称:CoinKata,代码行数:7,代码来源:CoinChanger_Funktional_mit_Fold.cs

示例13: SortNews

 private static List<NewsItem> SortNews(IEnumerable<NewsItem> items)
 {
     //Order by NewsByYear node, then by publish or create date
     return items.OrderByDescending(i => i.Parent<NewsByYear>().Name)
             .ThenByDescending(i => i.PublishDate != default(DateTime) ? i.PublishDate : i.CreateDate)
             .ToList();
 }
开发者ID:boblox,项目名称:Spadschyna-v2,代码行数:7,代码来源:NewsController.cs

示例14: GetUpdates

        public IEnumerable<IPackage> GetUpdates(IEnumerable<IPackage> packages, bool includePrerelease, bool includeAllVersions, IEnumerable<System.Runtime.Versioning.FrameworkName> targetFrameworks, IEnumerable<IVersionSpec> versionConstraints)
        {
            // only keep the latest version of each package Id to mimic the behavior of nuget.org GetUpdates() service method
            packages = packages.OrderByDescending(p => p.Version).Distinct(PackageEqualityComparer.Id);

            return this.GetUpdatesCore(packages, includePrerelease, includeAllVersions, targetFrameworks, versionConstraints);
        }
开发者ID:OsirisTerje,项目名称:sonarlint-vs,代码行数:7,代码来源:MockServiceBasePackageRepository.cs

示例15: PickNextTargets

 public override IEnumerable<IUnit> PickNextTargets(IEnumerable<IUnit> candidateTargets)
 {
     ////-picks 3 targets with most health points.
     //// If there are several targets with equal health points, picks those with alphabetically first name.
     this.ValidateTargets(candidateTargets);
     return candidateTargets.OrderByDescending(t => t.HealthPoints).ThenBy(t => t.Name).Take(3).ToList();
 }
开发者ID:EBojilova,项目名称:CSharp-OOP-June-2015,代码行数:7,代码来源:MageCombatHandler.cs


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