Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 962789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:33:55+00:00 2026-05-16T01:33:55+00:00

I am getting a response back from a Google Search Appliance suggest service in

  • 0

I am getting a response back from a Google Search Appliance suggest service in the form of JSON in the following format

string jsonString = @"{ ""query"": ""t"", ""results"": [ { ""name"": ""tom"", ""type"": ""suggest"" }, { ""name"": ""tim"", ""type"": ""suggest"" }]}";

I want to sort the results list by name alphabeticaly and change the names to sentence case.
I can do this in jquery but would prefer to do it on the server side for performance reasons.

I can sort the results but that returns an IEnumarable<Result> but I cant seem to sort the results within the object that is being serialised.

 string jsonString = @"{ ""query"": ""t"", ""results"": [ { ""name"": ""tom"", ""type"": ""suggest"" }, { ""name"": ""tim"", ""type"": ""suggest"" }]}";

JObject json = JObject.Parse(jsonString);

        var gsaSuggestions = JsonConvert.DeserializeObject<GSASuggestion>(jsonString);

        var orded = gsaSuggestions.ResultList.OrderBy<Result, string>(r => r.Name);

        string output = JsonConvert.SerializeObject(gsaSuggestions);
    }

    [JsonObject(MemberSerialization.OptOut)]
    public class GSASuggestion
    {
        [JsonProperty(PropertyName = "query")]
        public string Query {get; set;}
        [JsonProperty(PropertyName = "results")]
        public List<Result> ResultList {get; set;}
    }

    public class Result
    {
        [JsonProperty(PropertyName = "name")]
        public string Name {get; set;}
        [JsonProperty(PropertyName = "type")]
        public string Type {get; set;}
    }

the result should be:

{ "query": "t", "results": [ { "name": "Tim", "type": "suggest" }, { "name": "Tom", "type": "suggest" }]};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T01:33:55+00:00Added an answer on May 16, 2026 at 1:33 am

    You don’t actually use the return value of OrderBy. Try:

    gsaSuggestions.ResultList =
        gsaSuggestions.ResultList.OrderBy<Result, string>(r => r.Name).ToList();
    

    Remember, OrderBy returns a new sequence with the results in order, and does not modify the original sequence. If you want gsaSuggestions.ResultList to be sorted then you will need to assign a sorted list to it.

    You could also do an in-place sort using List.Sort:

    gsaSuggestions.ResultList.Sort((x, y) => x.Name.CompareTo(y.Name));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting json response from this google api service to get reverse geo
I'm getting the following (str) back from Disqus, JSON expected: ?({code: 0, response: {username:
I am getting response from web service in xml format and data are inside
I am getting JSON response from the server..Inside that JSON string i am having
I am getting json data as a response back from the server. I want
I'm getting a following response from the back-end servers to display the data as
I am attempting to parse some json I am getting back from a service.
I'm having trouble getting a response from my php jquery / json / ajax.
I'm having trouble getting a response back from a Jquery ajax call... (It's a
I have an array of 'tasks' that I am getting back from a JSON

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.