orderby list (from Json)

enrique_aeo used Ask the Experts™
hi experts

i have this list

  public class SAPArea
        public string CodDivision { get; set; }
        public string CodArea { get; set; }
        public string Nombre { get; set; }

public ActionResult ListarAreas()
            List<SAPArea> lista = new List<SAPArea>();

            lista = oPORTCliente.Get<List<SAPArea>>(string.Format("area/buscarArea?codDivision={0}&codArea={1}&nombre={2}", Constantes.CodDivision, string.Empty, string.Empty));

            return Json(new { result = 0, data = lista }, JsonRequestBehavior.AllowGet);

I need to sort the list by Nombre
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Try this:

 return Json(new { result = 0, data = lista.OrderBy(x=>x.Nombre ).ToList() }, JsonRequestBehavior.AllowGet);

Open in new window

Maybe calling ToList() is too much...


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial