c# var, linq

The codes below is working ok. I just need to make VAR response to be sorted.
How can I do that?

   public static List<Make> GetVehicleMakeList()
            List<Make> lstMake = new List<Make>();
            HttpClient objClient = new HttpClient();
                var response = objClient.GetStringAsync(Utility.Enumeration.vehicleMakeAPICall).Result;
                if (!string.IsNullOrEmpty(response))
                    VehicleMakeAPIResponse objMakeResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<VehicleMakeAPIResponse>(response);
                    return objMakeResponse.Results;

            catch (Exception ex)

                //log error message here
            return lstMake;

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Miguel OzSenior Software EngineerCommented:
Assuming you have to sor the result use linq order by

for example ascending order:
return objMakeResponse.Results.OrderBy(s => s.YourProperty);

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ITsolutionWizardAuthor Commented:
can you help me with using my codes?

I tried below and got alert. by the way, i would like to do sort (make_name) asc.

 return objMakeResponse.Results.OrderByDescending(s => s.Make_Name);
Fernando SotoRetiredCommented:
Hi ITsolutionWizard;

Depending on what kind of collection is being held by var response you may need to create an instance of a custom comparer to use with the OrderBy method. Please see the documentation below to see how to implement the OrderBy method.

Enumerable.OrderBy Method
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

Fernando SotoRetiredCommented:
And what did the alert state?
kaufmed   (⌐■_■)Shot Through the Heart, and You're to Blame, You Give vars a Bad NameCommented:
Your method returns a List<Make>, but OrderByDescending returns an IOrderedEnumerable. You'll want to either call ToList after OrderByDescending or change your method signature.
ITsolutionWizardAuthor Commented:
can you show me how with my codes?
Fernando SotoRetiredCommented:
In order to help you please tell us what is the data type being returned by the following statement?
var response = objClient.GetStringAsync(Utility.Enumeration.vehicleMakeAPICall).Result

Open in new window

ITsolutionWizardAuthor Commented:
List strong
Fernando SotoRetiredCommented:
List<XXX>, list of what, what object type is XXX? Please also post the class XXX.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.