public ActionResult list(string q = "", bool guid = false, string sortBy = "none") { // where we save the programs List <ProgramModel> programs = new List <ProgramModel>(); // determine the type of search to be performed if (guid) { ProgramModel.findGUID(q, programs); } else { ProgramModel.findName(q, programs); } // if we need to sort this if (sortBy != "none") { // define comparator IComparer <ProgramModel> comp; // select comparator if (sortBy == "name") { comp = new NameComparator(); } else { comp = new GUIDComparator(); } // sort programs.Sort(comp); } return(View(programs)); }