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


C# List.OrderByDescending方法代码示例

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


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

示例1: GetRankings

        public static List<Models.GameContext.Guild> GetRankings(int topNumber = 0, Models.GameContext.GuildRankingOrderBy orderBy = GuildRankingOrderBy.Score)
        {
            List<Models.GameContext.Guild> guilds = new List<Models.GameContext.Guild>();

            using (var context = new GameDbContext())
            {
                guilds = context.Guilds.ToList();

                if(orderBy == GuildRankingOrderBy.Name)
                {
                    guilds = guilds.OrderByDescending(x => x.G_Name).ToList();
                }

                if(orderBy == GuildRankingOrderBy.Score)
                {
                    guilds = guilds.OrderByDescending(x => x.G_Score).ToList();
                }

                if(topNumber > 0)
                {
                    guilds = guilds.Take(topNumber).ToList();
                }
            }

            return guilds;
        }
开发者ID:mathborba,项目名称:muwebnet,代码行数:26,代码来源:Guild.cs

示例2: Main

        static void Main(string[] args)
        {
            var products = new List<string>() {"Basketball", "Baseball", "Tennis Raquet", "Running Shoes", "Wrestling Shoes", "Soccer Ball", "Football", "Shoulder Pads",
                "Trail Running Shoes", "Cycling Shoes", "Kayak", "Kayak Paddles", "shoes1", "shoes2"};

            //declare a variable kayakProducts and set it equal to all products that contain the word "Kayak"
            var kayakProducts = products.Where(x => x.Contains("Kayak"));
            //print the kayakProducts to the console using a foreach loop.
            foreach (string item in kayakProducts)
            {
                Console.WriteLine(item);
            }
            //single line solution.  "\n" is a line break.
            Console.WriteLine(string.Join("\n", kayakProducts));

            //declare a variable shoeProducts and set it equal to all products that contain the word "Shoes"
            var shoeProducts = products.Where(x => x.Contains("Shoes")).ToList();

            //print the shoeProducts to the console using a foreach loop.
            Console.WriteLine(string.Join(", ", shoeProducts));

            //declare a variable ballProducts and set it equal to all the products that have ball in the name.
            var ballProducts = products.Where(x => x.ToLower().Contains("ball"));

            //print the ballProducts to the console using a foreach loop.
            Console.WriteLine(string.Join(", ", ballProducts));

            //sort ballProducts alphabetically and print them to the console.
            Console.WriteLine(string.Join(", ", ballProducts.OrderBy(x => x)));

            //add six more items to the products list using .add().
            //add multiple products individually, but on the same line
            products.Add("ice axe"); products.Add("crampons"); products.Add("trekking poles");
            //add multiple products at the same time
            products.AddRange(new List<string>() { "baseball bases", "baseball helmet" });

            Console.WriteLine(string.Join(", ", ballProducts.OrderBy(x => x)));

            //print the product with the longest name to the console using the .First() extension.
            Console.WriteLine(products.OrderByDescending(x => x.Length).First());
            //print the product with the shortest name to the console using the .Last() extension.
            Console.WriteLine(products.OrderByDescending(x => x.Length).Last());

            //print the product with the 4th shortest name to the console using an index (you must convert the results to a list using .ToList()).
            Console.WriteLine(products.OrderBy(x => x.Length).Skip(3).Take(1).First());

            //print the ballProduct with the 2nd longest name to the console using an index(you must convert the results to a list using .ToList()).
            Console.WriteLine(ballProducts.OrderByDescending(x => x.Length).ToList()[1]);

            //declare a variable reversedProducts and set it equal to all products ordered by the longest word first. (use the OrderByDecending() extension).

            //print out the reversedProducts to the console using a foreach loop.

            //print out all the products ordered by the longest word first using the OrderByDecending() extension and a foreach loop.
            //You will not use a variable to store your list

            Console.WriteLine(string.Join(", ", products.OrderByDescending(x => x.Length).ThenBy(x=> x)));

            Console.ReadKey();
        }
开发者ID:Ketenks,项目名称:SeedPathsSolutions,代码行数:60,代码来源:Program.cs

示例3: SortCars

        public List<Car> SortCars(string sortOrder, List<Car> carsList)
        {
            List<Car> SortedList;
            switch (sortOrder)
            {
                case "price":
                    {
                        SortedList = carsList.OrderBy(o => o.Price).ToList();
                        break;
                    }
                case "mileage":
                    {
                        SortedList = carsList.OrderBy(o => o.Mileage).ToList();
                        break;
                    }
                case "price_desc":
                    {
                        SortedList = carsList.OrderByDescending(o => o.Price).ToList();
                        break;
                    }
                case "mileage_desc":
                    {
                        SortedList = carsList.OrderByDescending(o => o.Mileage).ToList();
                        break;
                    }
                default:

                    SortedList = carsList;
                    break;
            }
            return SortedList;
        }
开发者ID:Naresh-Nelavalli,项目名称:TraumenAuto,代码行数:32,代码来源:Manager.cs

示例4: AjustarBindServicos

        private void AjustarBindServicos(List<ServicoDTO> servicos)
        {
            if (servicos.OrderByDescending(q => q.idServico).FirstOrDefault() != null)
                idServicoAux = servicos.OrderByDescending(q => q.idServico).FirstOrDefault().idServico;

            dgvServicos.DataSource = servicos;
            dgvServicos.Columns[0].Visible = false;
            dgvServicos.Columns[1].Visible = false;
            dgvServicos.Columns[2].Visible = false;
            dgvServicos.Columns[3].Visible = false;
            dgvServicos.Columns[4].Visible = false;
            dgvServicos.Columns[12].Visible = false;
            dgvServicos.Columns[13].Visible = false;
            dgvServicos.Columns[14].Visible = false;
            dgvServicos.Columns[15].Visible = false;
            dgvServicos.Columns[16].Visible = false;

            dgvServicos.Columns[6].HeaderText = "Entrega pelo";
            dgvServicos.Columns[7].HeaderText = "Objetos Declarados";
            dgvServicos.Columns[7].Width = 300;
            dgvServicos.Columns[8].HeaderText = "Observação do Cliente";
            dgvServicos.Columns[8].Width = 300;
            dgvServicos.Columns[9].HeaderText = "Status Serviço";
            dgvServicos.Columns[11].HeaderText = "Serviço";

            dgvServicos.Columns[10].DataPropertyName = "dtInicio";
            dgvServicos.Columns[10].HeaderText = "Início";
            dgvServicos.Columns[10].Width = 120;

            dgvServicos.Columns[12].DataPropertyName = "dtFim";
            dgvServicos.Columns[12].HeaderText = "Fim";
            dgvServicos.Columns[12].Width = 120;
        }
开发者ID:tonfranco,项目名称:LR,代码行数:33,代码来源:frmCadCliente.cs

示例5: GetTopCommentList

        protected static List<Comment> GetTopCommentList(Comment[] allComments)
        {
            List<Comment> topComments = new List<Comment>();

            foreach (Comment comment in allComments)
            {
                // Builds and sorts empty list until sufficiently large
                if (topComments.Count() < TOP_COMMENTS_TO_GRAB)
                {
                    topComments.Add(comment);
                    topComments = topComments.OrderByDescending(c => c.Upvotes).ToList();
                }
                else
                {
                    foreach (Comment topComment in topComments)
                    {
                        if (comment.Upvotes > topComment.Upvotes)
                        {
                            // Compares comment against descending list and then re-sorts once inserted
                            topComments.Remove(topComment);
                            topComments.Add(comment);
                            topComments = topComments.OrderByDescending(c => c.Upvotes).ToList();
                            break;
                        }
                    }
                }
            }

            return topComments;
        }
开发者ID:JosephDomenici,项目名称:Reddit-Readability-Bot,代码行数:30,代码来源:Methods.cs

示例6: FourOfAKind

        /// <summary>
        /// Sets the player type if his hand type is four of a kind.
        /// </summary>
        public void FourOfAKind(IPlayer player, int[] straight, List<Type> winners, ref Type sorted)
        {
            if (player.HandType >= -1)
            {
                for (int j = 0; j <= 3; j++)
                {
                    if (straight[j] / 4 == straight[j + 1] / 4 && straight[j] / 4 == straight[j + 2] / 4
                        && straight[j] / 4 == straight[j + 3] / 4)
                    {
                        player.HandType = 7;
                        player.HandPower = (straight[j] / 4) * 4 + player.HandType * 100;
                        winners.Add(new Type() { Power = player.HandPower, Current = 7 });
                        sorted = winners.OrderByDescending(op1 => op1.Current).ThenByDescending(op1 => op1.Power).First();
                    }

                    if (straight[j] / 4 == 0 && straight[j + 1] / 4 == 0 && straight[j + 2] / 4 == 0
                        && straight[j + 3] / 4 == 0)
                    {
                        player.HandType = 7;
                        player.HandPower = (13 * 4) + (player.HandType * 100);
                        winners.Add(new Type() { Power = player.HandPower, Current = 7 });
                        sorted = winners.OrderByDescending(op1 => op1.Current).ThenByDescending(op1 => op1.Power).First();
                    }
                }
            }
        }
开发者ID:Banana-Team,项目名称:Poker,代码行数:29,代码来源:AssertHandType.cs

示例7: Index

        public ActionResult Index(int? page, int? PageSize, string sortBy)
        {
            var customers = new List<DSC_CUSTOMER>();
            var viewCustomers = new List<CustViewModel>();
            ViewBag.CurrentItemsPerPage = PageSize ?? 10;
            ViewBag.SortNameParameter = String.IsNullOrEmpty(sortBy) ? "Name desc" : "Name";
            ViewBag.SortParentParameter = sortBy == "Parent" ? "Parent desc" : "Parent"; 

            using (DSC_OBS_DB_ENTITY db = new DSC_OBS_DB_ENTITY())
            {
                customers = db.DSC_CUSTOMER.Where(cust_id => cust_id.dsc_cust_id > 0).ToList();
            }
            //DateTime active_date;
            foreach (DSC_CUSTOMER customer in customers)
            {
                string activeAction = "";
                try
                {
                    if (customer.dsc_cust_eff_end_date == null)
                    {
                        activeAction = "YES";

                    }//end of if
                    else
                    {
                        if (customer.dsc_cust_eff_end_date <= DateTime.Today)
                        {
                            activeAction = "NO";
                        }
                        else
                        {
                            activeAction = "YES";
                        }
                    }//end of else
                }//end of try
                catch
                {
                    activeAction = "NO";
                }//end of catch

                viewCustomers.Add(new CustViewModel(customer.dsc_cust_id, customer.dsc_cust_name, customer.dsc_cust_parent_name, activeAction, activeAction == "YES" ? "Deactivate" : "Activate"));
            }// end of foreach
            switch (sortBy)
            {
                case "Name desc":
                    return View(viewCustomers.OrderByDescending(x=>x.dsc_cust_name).ToPagedList(page ?? 1, PageSize ?? 10));
                case "Parent desc":
                    return View(viewCustomers.OrderByDescending(x => x.dsc_cust_parent_name).ToPagedList(page ?? 1, PageSize ?? 10));
                case"Name":
                    return View(viewCustomers.OrderBy(x => x.dsc_cust_name).ToPagedList(page ?? 1, PageSize ?? 10));
                case "Parent":
                    return View(viewCustomers.OrderBy(x => x.dsc_cust_parent_name).ToPagedList(page ?? 1, PageSize ?? 10));
                default: return View(viewCustomers.ToPagedList(page ?? 1, PageSize ?? 10));


            }

            
            
        }
开发者ID:dsclogistics,项目名称:OBSMVC,代码行数:60,代码来源:CustController.cs

示例8: GetUserOrders

        public JsonResult GetUserOrders(int type,string userid, string teamid, string beginTime, string endTime,string ordertype)
        {

            var list = SalesRPTBusiness.BaseBusiness.GetUserOrders(userid, teamid, beginTime, endTime, CurrentUser.AgentID, CurrentUser.ClientID, ordertype);

            if (type == 2)
            {
                Dictionary<string, List<TypeOrderEntity>> customerlist =  new Dictionary<string, List<TypeOrderEntity>>(); 
                
                List<TypeOrderEntity> listcustomer = new List<TypeOrderEntity>();
                list.ForEach(x => listcustomer.AddRange(x.ChildItems));
                customerlist.Add("TotalList", listcustomer.OrderByDescending(x =>  x.TCount).Take(15).ToList());
                customerlist.Add("MoneyList", listcustomer.OrderByDescending(x =>  x.TMoney).Take(15).ToList());
                JsonDictionary.Add("items", customerlist);
            }
            else
            {
                JsonDictionary.Add("items", list);
            }
            return new JsonResult()
            {
                Data = JsonDictionary,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };
        }
开发者ID:yunxiaokeji,项目名称:ErDangJia,代码行数:25,代码来源:SalesRPTController.cs

示例9: FetchListOfChildren

        public JqGridData FetchListOfChildren(Person currentPerson, JqGridRequest request, string[] selectedRoles)
        {
            IEnumerable<ChildReportDto> listOfChildren = new List<ChildReportDto>();
            try
            {
                listOfChildren = _childrenReportsRepository.GetListOfChildrenForAChurch(currentPerson, ConversionService.ConvertSelectedRolesToListOfInts(selectedRoles));
            }
            catch (Exception ex)
            {
                _emailService.SendExceptionEmail(ex);
            }

            var totalRecords = listOfChildren.Count();

            switch (request.sidx)
            {
                case "Age":
                    {
                        listOfChildren = request.sord.ToLower() == "asc" ? listOfChildren.OrderBy(p => p.Age).Skip((request.page - 1) * request.rows).Take(request.rows) : listOfChildren.OrderByDescending(p => p.Age).Skip((request.page - 1) * request.rows).Take(request.rows);
                        break;
                    }
                case "Surname":
                    {
                        listOfChildren = request.sord.ToLower() == "asc" ? listOfChildren.OrderBy(p => p.Surname).Skip((request.page - 1) * request.rows).Take(request.rows) : listOfChildren.OrderByDescending(p => p.Surname).Skip((request.page - 1) * request.rows).Take(request.rows);
                        break;
                    }
                case "Firstname":
                    {
                        listOfChildren = request.sord.ToLower() == "asc" ? listOfChildren.OrderBy(p => p.Firstname).Skip((request.page - 1) * request.rows).Take(request.rows) : listOfChildren.OrderByDescending(p => p.Firstname).Skip((request.page - 1) * request.rows).Take(request.rows);
                        break;
                    }
            }

            var childrenGridData = new JqGridData()
            {
                total = (int) Math.Ceiling((float) totalRecords/request.rows),
                page = request.page,
                records = totalRecords,
                rows = (from p in listOfChildren.AsEnumerable()
                    select new JqGridRow()
                    {
                        id = p.PersonId.ToString(),
                        cell = new[]
                        {
                            p.PersonId.ToString(),
                            p.Age.ToString(),
                            p.Firstname,
                            p.Surname,
                            p.CellNo,
                            p.GroupName,
                            p.Father,
                            p.Mother

                        }
                    }).ToArray()
            };

            return childrenGridData;
        }
开发者ID:petermunnings,项目名称:funwithoiky,代码行数:59,代码来源:ChildReportsService.cs

示例10: Execute

        public void Execute()
        {
            var persons = new List<Person>
            {
                new Person {Id = 1001, Name = "gsf_zero1"},
                new Person {Id = 1000, Name = "gsf_zero2"},
                new Person {Id = 111, Name = "gsf_zero3"},
                new Person {Id = 9889, Name = "gsf_zero4"},
                new Person {Id = 9889, Name = "gsf_zero5"},
                new Person {Id = 100, Name = "gsf_zero6"}
            };

            //
            // 順序付け演算子には、以下のものが存在する。
            //
            //   ・OrderBy
            //   ・OrderByDescending
            //   ・ThenBy
            //   ・ThenByDescending
            //
            // OrderByは昇順ソート、OrderByDescendingは降順ソートを行う。どちらも単一キーにてソートを行う。
            // 複合キーにて、ソート処理を行う場合は、OrderBy及びOrderByDescendingに続いて、ThenBy及びThenByDescendingを利用する。
            //
            // OrderBy及びOrderByDescendingメソッドは、他のLINQ標準演算子と戻り値が異なっており
            //   IOrderedEnumerable<T>
            // を返す。また、ThenBy及びThenByDescendingメソッドは、引数にIOrderedEnumerable<T>を渡す必要がある。
            // なので、必然的に、ThenByはOrderByの後で呼び出さないと利用出来ない。
            //
            // LINQの並び替え処理は、安定ソート(Stable Sort)である。
            // つまり、同じキーの要素がシーケンス内に複数存在した場合、並び替えた結果は元の順番を保持している。
            //

            //
            // IDで昇順ソート.
            //
            var sortByIdAsc = persons.OrderBy(aPerson => aPerson.Id);

            Output.WriteLine("================= IDで昇順ソート =================");
            Output.WriteLine(string.Join(Environment.NewLine, sortByIdAsc));

            //
            // IDで降順ソート.
            //
            var sortByIdDesc = persons.OrderByDescending(aPerson => aPerson.Id);

            Output.WriteLine("================= IDで降順ソート =================");
            Output.WriteLine(string.Join(Environment.NewLine, sortByIdDesc));

            //
            // 安定ソートの確認。
            //
            var sortByIdAscAndDesc = persons.OrderByDescending(aPerson => aPerson.Id).OrderBy(aPerson => aPerson.Id);

            Output.WriteLine("================= 安定ソートの確認 =================");
            Output.WriteLine(string.Join(Environment.NewLine, sortByIdAscAndDesc));
        }
开发者ID:devlights,项目名称:Sazare,代码行数:56,代码来源:LinqSamples22.cs

示例11: SearchResult

        // GET: Search
        public ActionResult SearchResult(int? page)
        {
            var searchCriteria = Session["SearchCriteria"] as string;
            if (searchCriteria == null)
                return RedirectToAction("Error404", "Home");
            var records = db.Models.Where(x => x.ModelNumber.Contains(searchCriteria) && x.Status == "Active").ToList();

            var searchList = new List<SearchResultViewModel>();
            foreach (var item in records)
            {
                var searchItem = new SearchResultViewModel()
                {
                    ModelId = item.ModelId,
                    ModelName = item.ModelNumber,
                    Price = item.Price,
                    ImageUrl = (from ph in db.Photos
                                join pm in db.PhotoModels on ph.PhotoId equals pm.PhotoId
                                join m in db.Models on pm.ModelId equals m.ModelId
                                where pm.ModelId == item.ModelId
                                select ph.ImageUrl).FirstOrDefault(),

                    DtCreated = item.DtCreated,
                    CategoryName = (from c in db.Categories
                                    join p in db.Products on c.CategoryId equals p.CategoryId
                                    join i in db.Items on p.ProductId equals i.ProductId
                                    join m in db.Models on i.ItemId equals m.ItemId
                                    where m.ItemId == item.ItemId
                                    select c.Description).FirstOrDefault(),

                    ProductName = (from c in db.Categories
                                   join p in db.Products on c.CategoryId equals p.CategoryId
                                   join i in db.Items on p.ProductId equals i.ProductId
                                   join m in db.Models on i.ItemId equals m.ItemId
                                   where m.ItemId == item.ItemId
                                   select p.Description).FirstOrDefault(),

                    ItemName = (from c in db.Categories
                                join p in db.Products on c.CategoryId equals p.CategoryId
                                join i in db.Items on p.ProductId equals i.ProductId
                                join m in db.Models on i.ItemId equals m.ItemId
                                where m.ItemId == item.ItemId
                                select i.Description).FirstOrDefault()
                };
                searchList.Add(searchItem);
            }
            int count = records.Count();
            ViewBag.Count = count;
            ViewBag.Model = searchCriteria.ToString();
            Session.Remove("SearchCriteria");

            var pageNumber = page ?? 1;
            var pageOfProducts = searchList.OrderByDescending(s => s.DtCreated).ToPagedList(pageNumber, 10);
            ViewBag.pageOfProducts = pageOfProducts;

            return View(searchList.OrderByDescending(s => s.DtCreated));
        }
开发者ID:bontobuy,项目名称:BontoBuy.Web,代码行数:57,代码来源:SearchController.cs

示例12: findNearestNeighbours

        private List<Photon> findNearestNeighbours(int number, Vector3 point, List<Photon> currentBest, int depth)
        {
            //If we are not a leaf node and we don't have any current bests, recurse down the tree 
            if (currentBest.Count == 0 && !isLeaf())
            {
                if (getComponentFromDepth(point, depth) < getComponentFromDepth(p.position, depth))
                {
                    currentBest = left.findNearestNeighbours(number, point, currentBest, depth + 1);
                }
                else if (right != null)
                {
                    currentBest = right.findNearestNeighbours(number, point, currentBest, depth + 1);
                }
            }

            //If there aren't enough points yet, add this one and return
            if (currentBest.Count < number)
            {
                currentBest.Add(p);
            }
            //Else see if any of the points are farther
            else
            {
                currentBest.OrderByDescending(x => (x.position - point).LengthSquared);
                //If so, remove the farthest, add this one, and return
                if ((currentBest[0].position - point).LengthSquared > (p.position - point).LengthSquared)
                {
                    currentBest.RemoveAt(0);
                    currentBest.Add(p);
                }
            }

            //If we are a leaf we are done
            //Otherwise we have to check to see if there might be points on the other side of the splitting
            //  plane which are closer than the current best, farthest point
            if (!isLeaf())
            {
                currentBest.OrderByDescending(x => (x.position - point).LengthSquared);
                float difference = getComponentFromDepth(point, depth) - getComponentFromDepth(p.position, depth);
                if ((currentBest[0].position - point).LengthSquared > difference * difference)
                {
                    if (difference < 0)
                    {
                        currentBest = left.findNearestNeighbours(number, point, currentBest, depth + 1);
                    }
                    else if (right != null)
                    {
                        currentBest = right.findNearestNeighbours(number, point, currentBest, depth + 1);
                    }
                }
            }

            return currentBest;
        }
开发者ID:ChewyGumball,项目名称:dragonage-lightmapper,代码行数:54,代码来源:KDTree.cs

示例13: FillGrid

        public void FillGrid()
        {
            TTSHWCFServiceClient client = new TTSHWCFServiceClient();

            List<Feasibility_Grid> gridData = new List<Feasibility_Grid>();

            gridData = client.Feasibility_FillGrid().ToList();

            try
            {
                string UserID = Convert.ToString(Session["UserID"]).ToUpper();
                Project_DataOwner[] oDOList = client.GetProjectsByDO("FEASIBILITY", UserID);
                DataOwner_Entity[] oDataOwner = client.GetAllDataOwner("TAdmin");

                var AdminArray = (from s in oDataOwner
                                  select s.GUID).ToList();

                bool IsAdmin = AdminArray.Contains(UserID);

                if (IsAdmin == false)
                {
                    List<Feasibility_Grid> oNewGrid = new List<Feasibility_Grid>();
                    if (gridData != null && gridData.Count() > 0 && oDOList != null && oDOList.Count() > 0)
                    {
                        var v = gridData.Select(z => z.Feasibility_Status_Name).Distinct().ToList();
                        oNewGrid = gridData.Where(z => z.Feasibility_Status_Name.ToUpper() == "NEW").Where(z => oDOList.Any(x => x.s_DisplayProject_ID == z.s_Display_Project_ID)).ToList();
                        oNewGrid.ForEach(i => i.Status = "New");
                        gridData.RemoveAll(z => z.Feasibility_Status_Name.ToUpper() == "NEW");
                        gridData.AddRange(oNewGrid);
                        gridData.Where(z => z.Feasibility_Status_Name.ToUpper() != "NEW").Where(z => oDOList.Any(x => x.s_DisplayProject_ID.ToUpper().Trim() != z.s_Display_Project_ID.ToUpper().Trim())).ToList().ForEach(i => i.Status = "View");
                        gridData.Where(z => z.Feasibility_Status_Name.ToUpper() != "NEW").Where(z => oDOList.Any(x => x.s_DisplayProject_ID.ToUpper().Trim() == z.s_Display_Project_ID.ToUpper().Trim())).ToList().ForEach(i => i.Status = "Edit");
                        gridData = gridData.OrderByDescending(z => z.i_Project_ID).ToList();
                    }
                }
                else
                {
                    gridData.Where(z => z.Feasibility_Status_Name.ToUpper() == "NEW").ToList().ForEach(i => i.Status = "New");
                    //gridData.Where(z => z.Feasibility_Status_Name.ToUpper() != "NEW").ToList().ForEach(i => i.Status = "View");
                    gridData.Where(z => z.Feasibility_Status_Name.ToUpper() != "NEW").ToList().ForEach(i => i.Status = "Edit");
                    gridData = gridData.OrderByDescending(z => z.i_Project_ID).ToList();
                }
            }
            catch (Exception ex1)
            {

            }

            rptrProjectDetail.DataSource = gridData;

            rptrProjectDetail.DataBind();
        }
开发者ID:nitinV-Click2Cloud,项目名称:EnterpriseLevel,代码行数:51,代码来源:FeasibilityDetails.aspx.cs

示例14: Index

        public ActionResult Index(string sortOrder, int page=1)
        {
            PageInfo pageInfo = new PageInfo(PageConstants.itemsPerPage, page);
            NewsIndexModelView nivm = new NewsIndexModelView();
            nivm.PageInfo = pageInfo;



            List<News> sortedNews = new List<News>();
            if (User.IsInRole(Constants.UserRoles.AdminRoleName))
            {
                sortedNews = newsManagement.news.ToList<News>();
            }
            else
            {
                foreach (var item in newsManagement.news)
                {
                    if (item.IsVisible || User.Identity.Name == item.AuthorsID)
                    {
                        sortedNews.Add(item);
                    }
                }
            }
            switch (sortOrder)
            {
                case "name_desc":
                    sortedNews = sortedNews.OrderByDescending(s => s.AuthorsID).ToList();
                    break;
                case "Date":
                    sortedNews = sortedNews.OrderBy(s => s.Date).ToList();
                    break;
                case "date_desc":
                    sortedNews = sortedNews.OrderByDescending(s => s.Date).ToList();
                    break;
                default:
                    sortedNews = sortedNews.OrderBy(s => s.AuthorsID).ToList();
                    break;
            }

            ArticleSorting sortingParam = new ArticleSorting();

            sortingParam.CurrentSort = sortOrder;
            sortingParam.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            sortingParam.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date";

            nivm.ArticleSort = sortingParam;
            nivm.News = sortedNews.Skip((page - 1) * PageConstants.itemsPerPage).Take(PageConstants.itemsPerPage).ToList<News>(); ;
            nivm.PageInfo.TotalItems = sortedNews.Count;

            return View(nivm);
        }
开发者ID:akhroponiuk,项目名称:NewFolder,代码行数:51,代码来源:NewsController.cs

示例15: dropBadSubnets

        //удаление заданного кол-ва сетей по возрастанию
        public static List<Subnet> dropBadSubnets(List<Subnet> subnets, int count)
        {
            //сортировка по убыванию
            subnets = subnets.OrderByDescending(net => net.ID).ToList();
            subnets = subnets.OrderByDescending(net => net.quality).ToList();

            for (int i = 0; i < count; i++)
            {
                //удаление худших с конца
                subnets.RemoveAt(subnets.Count - 1);
            }

            return subnets;
        }
开发者ID:ArtemAdamenko,项目名称:ANNBuilder-Genetic,代码行数:15,代码来源:ANNUtils.cs


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