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 6975393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:21:44+00:00 2026-05-27T17:21:44+00:00

Odrer ID Descrption Type Envelope K205 Green Paper >>>>String Line with space in between

  • 0
 Odrer     ID    Descrption    Type 

Envelope  K205    Green       Paper     >>>>String Line with space in between
Box       J556    Yellow      Thermocol >>>>String Line with space in between
Envelope  L142    White       Plastic   >>>>String Line with space in between

I have a table something like above and I have to provide options sort the
data based on the column name, like “sort by Order”, “Sort By Type” something like that
plz suggest me the best ideas to achieve this in Java… The table rows are strings with
space separating each touple..

  • 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-27T17:21:45+00:00Added an answer on May 27, 2026 at 5:21 pm

    Represent each row in your table as an object with order, id, description and type attributes. Add each object to a collection such as a list. You can then create different comparators such as an OrderComparator and a TypeComparator to sort the collection based on order or type respectively.

    For example, here is what your data class might look like:

    public class Data{
        private final String order;
        private final String id;
        private final String description;
        private final String type;
    
        public Data(String order, String id, String description, String type) {
            this.order=order;
            this.id=id;
            this.description=description;
            this.type=type;
        }
    
        /** getter methods here **/
    }
    

    Now, you would add them to a list and use a specific comparator to sort it:

    //add data to a list
    List<Data> list = new ArrayList<Data>();
    list.add(new Data("Envelope","K205","Green","Paper"));
    list.add(new Data("Box","J556","Yellow","Thermocol"));
    list.add(new Data("Envelope","L142","White","Plastic"));
    
    //create a comparator to sort by type
    Comparator<Data> typeComparator = new Comparator<Data>() {
        @Override
        public int compare(Data o1, Data o2) {
            return o1.getType().compareTo(o2.getType());
        }
    };
    
    //sort the list
    Collections.sort(list, typeComparator);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a custom type Foo : public class Foo { public string
I have the following models: class Order_type(models.Model): description = models.CharField() class Order(models.Model): type= models.ForeignKey(Order_type)
Given these types: [DataContract] public class EntityId { [DataMember(Order = 1)] public string IdAsString
I am working with the following SQL query: SELECT a.AppointmentId, a.Status, a.Type, a.Title, b.Days,
I have column with the type ntext , and I would like to convert
I have orders details as serialized in the TEXT Type of mysql field. Recently
I have objects: type A (Id, Name), type B (AId, Description). I want to
I have a type mismatch in my VBScript script. I know that the value
The issue lies in the following: filter :contact, :as => :string works successfully if
I have a simple list-type php page, which lists items according to a mysql

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.