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

  • Home
  • SEARCH
  • 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 8182861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:59:06+00:00 2026-06-07T00:59:06+00:00

I have google’d it, and tried some examples, but I always get stuck. This

  • 0

I have google’d it, and tried some examples, but I always get stuck.

This is the error message, when I try to use the Collections.sort:

The generic method sort(List<T>) of type Collections is not applicable for the arguments (ArrayList<HashMap<String,String>>). The inferred type HashMap<String,String> is not a valid substitute for the bounded parameter <T extends Comparable<? super T>>.

My code is similar to this one.

ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();

//Get the data (see above)
JSONObject json = JSONfunctions.getJSONfromURL("http://xxxxxxxxxxxxxxxxxxxxxx");

try {
    //Get the element that holds the earthquakes ( JSONArray )
    JSONArray earthquakes = json.getJSONArray("earthquakes");

    //Loop the Array
    for (int i = 0; i < earthquakes.length(); i++) {
        HashMap<String, String> map = new HashMap<String, String>();
        JSONObject e = earthquakes.getJSONObject(i);

        map.put("id", String.valueOf(i));
        map.put("name", "Earthquake name:" + e.getString("eqid"));
        map.put("magnitude", "Magnitude: " + e.getString("magnitude"));
        mylist.add(map);
    }
} catch (JSONException e) {
    Log.e("log_tag", "Error parsing data " + e.toString());
}

ListAdapter adapter = new SimpleAdapter(this, mylist, R.layout.main,
        new String[]{"name", "magnitude"},
        new int[]{R.id.item_title, R.id.item_subtitle});

setListAdapter(adapter);
  • 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-06-07T00:59:08+00:00Added an answer on June 7, 2026 at 12:59 am

    As already explained by @pcalcao, you need to decide how you are going to sort the maps (based on what criteria), then implement that sort order in a custom comparator and call Collections.sort with that comparator.

    For example, let’s say you want to sort by alphabetical order of names, you would write something like:

    Collections.sort(mylist, new Comparator<Map<String, String>>() {
    
        @Override
        public int compare(Map<String, String> o1, Map<String, String> o2) {
            String name1 = o1.get("name");
            String name2 = o2.get("name");
            if (name1 == null) return -1;
            return name1.compareTo(name2);
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am really struggling with this one. I have Google'd this and tried most
I have Google this question for almost a whole day, but still not answer.
Outline OK, I have Google'd this and already expecting a big fat NO!! But
I have google the heck out of this an I cannot get an answer
I have google chrome on two computers here. Both run XP. I get some
I have google this a lot but couldnt find any thing , how do
We have used Google form, Wufoo form to try to securely capture the info
Hi I don't know how to to do this in iphone. I have google
Get location(lat/long) without GPS, just like my location feature in Google maps. I have
I have learned that type fields is an error-prone technique somewhere I have Google

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.