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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:42:13+00:00 2026-05-22T12:42:13+00:00

Since I’m using Java 1.4.2, this means that I cannot use Java’s implementation of

  • 0

Since I’m using Java 1.4.2, this means that I cannot use Java’s implementation of the table sorter. Instead, I’ve been using the TableSorter.java class from an earlier reply to my previous post:
Heads up on implementing rowsorter and rowfilter java 1.4

It’s working perfectly with one problem however, which is that it doesn’t sort numeric values correctly. For instance, I have the following sequence of numbers in my table:
5,18,9,7,2,33

A increasing order sorting would display them like this in my JTable:

18,2,33,5,7,9

A decreasing order sorting would display them like this in my JTable:
9,7,5,33,2,18

I don’t know if you have realized it, but apparently, the sorting of numeric values is only happening based on the first digit.

Do you have any quick fix for the problem? Please bare in mind that those numeric values are used as strings in my JTable as suggested by the getValue() method.

  • 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-22T12:42:13+00:00Added an answer on May 22, 2026 at 12:42 pm

    To update you guys on this, what I did was to replace the LEXICAL_COMPARATOR in the TableSorter.java from my original post with this:


    public static final Comparator LEXICAL_COMPARATOR = new Comparator() {
    public int compare(Object o1, Object o2) {
    if(o1 instanceof Integer)
    {
    Integer firstNumeric, secondNumeric;

                firstNumeric =(Integer)o1;
                secondNumeric= (Integer)o2;
    
                        return firstNumeric.compareTo(secondNumeric);
    
    
            }
            else
            return o1.toString().compareTo(o2.toString());
        }
    };
    

    Now, in the getValueAt, make sure that your “int” values are cast into Integer by simply doing:
    new Integer(intValue);

    I hope this will save people some time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since basic auth has been deprecated, is the official android twitter app using OAuth?
Since Java 5, we've had boxing/unboxing of primitive types so that int is wrapped
Since both a Table Scan and a Clustered Index Scan essentially scan all records
Since the keyboard is the interface we use to the computer, I've always thought
Since the release of Adobe AIR I am wondering why Java Web Start has
Since I'm used to developing in Java, I'm familiar with what files get generated
since last four years i had been coding in c/c++, but those lenthy programs
Since it's possible using the IsNumeric() and others VB.NET functions from IronPython by importing
Since upgrading to Helios, some of my main shortcuts have stopped working; I use
Since black red tree is a binary search tree I have decided to use

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.