orderby list (from Json)

enrique_aeo
enrique_aeo used Ask the Experts™
on
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
www.png
Comment
Watch Question

Do more with

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

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...

Giannis

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