Problem - Sort output in table (multiple columns)

Dear all,
First of all - Best wishes for 2008.
I probably have an easy matter, but i can't figure it out, and on this forum very little is mentioned about the sort operator, so therefore this new post.
I have a dashboard with some input fields (dropdown boxes).
I have a table (as result of query) and this works fine. The table consists of several columns. (so far no rocket science).
Generally the structure of the table is like:
IM SBU | App. Request key | App. Request | etc....
I want the IM SBU colum to be sorted (assending or decending doenst matter).
But somehow the second column is the one where the data is sorted (standard).
My guess this happends because its a key value? or its because it starts with an A (and the other with and I).
So i insert the sort opperator, add an object (IM SBU) and select up. Then from that opperator i create a table.
This results in a table with just 1 column (IM SBU).
So i tried several things.
I tried to sort on the IM SBU key (this gives the same result).
I added all colums as an object of the sort opperator...but this still gives the same result of just 1 column.
Any ideas?
Regards.
Bart

Dear all.
I'm wondering if  anybody else experienced errors with the sort and the amount of columns shown in a table????
In general i have a query and want a table as output with 8 columns (sorted by 1 object). I figured out the following and will demonstrate it with 4 situations.
Situation1 (auto fit table without sort)
In the properties of the table i select 'frame style'= 'Primary frame' and "fit content" = 'auto'. I run the dashboard and the content of the query is good. All columns are shown and the chart width is auto determined.
Situation 2 (auto fit table with sort)
I want to sort on 1 object, so from query i insert a sort (select object), and from sort i create table. Then i select 'frame style'= 'Primary frame' and "fit content" = 'auto'. I run the dashboard and the content of the query is NOT good. I just get to see 1 column. But i selected 8 columns.
Situation 3 (actual fit table with sort)
I want to sort on 1 object, so from query i insert a sort, and from sort i create table. Then i select 'frame style'= 'Primary frame' and select "fit content" = 'actual size'. I run the dashboard and the content of the query is good (but not what i want). I get to see all 8 columns. But the table is smaller than i want. I doenst auto fit.
Situation 4 (fit width table with sort)
I want to sort on 1 object, so from query i insert a sort (select object), and from sort i create table. Then i select 'frame style'= 'Primary frame' and "fit content" = 'fit width'. I run the dashboard and the content of the query is NOT good. I just get to see 1 column (again). But i selected 8 columns.
Any suggestions?
Any known work arounds?
Or is this an error in VC and should i request a note?
Regards.
Bart

Similar Messages

  • Sorting records based on multiple columns

    Hi All,
    Please provide SQK query to sort the records in multiple columns
    based on NON NULL and NULL values.
    SID SNUMBER UNIT COUNTRY  STATE
    0 M14762 DE 0
    NULL    NULL            NULL    NULL
    0 990 GB
    0 M14704 IE 0
      M14767 IE 0
    0 M14704 FR 0
    0 M15351 990 GB
              FR 0
    0 D10693 800 GB 0
    NULL    NULL            NULL    NULL
    0 D10693 800 GB 0
    If all column values are NOT NULL those records should come first.
    If first column(SID) values are NOT NULL those records should come next.
    If second column(SNUMBER) values are NOT NULL those records should come next.
    If third column(UNIT) values are NOT NULL those records should come next.
    If fourth column(COUNTRY) values are NOT NULL those records should come next.
    If fifth column(STATE) values are NOT NULL those records should come next.
    If all the column values are NULL those records should come last.
    The output should be like this.
    SID SNUMBER UNIT COUNTRY  STATE
    0 D10693 800 GB 0
    0 D10693 800 GB 0
    0 M14762 DE 0
    0 990 GB
    0 M14704 IE 0
    0 M14704 FR 0
    0 M15351 990 GB
      M14767 IE 0
              FR 0
    NULL    NULL            NULL    NULL
    NULL    NULL            NULL    NULL
    Please help me.
    Thanks.

    Hi,
           For Your Requirement,
    SELECT COALESCE (SID, snumber, unit, country, state) SID,
           (CASE
               WHEN SID IS NULL
               AND snumber IS NOT NULL
               AND unit IS NOT NULL
               AND country IS NOT NULL
               AND state IS NOT NULL
                  THEN unit
               WHEN SID IS NOT NULL
               AND snumber IS NULL
               AND country IS NOT NULL
               AND unit IS NOT NULL
               AND state IS NOT NULL
                  THEN unit
               WHEN SID IS NOT NULL AND snumber IS NOT NULL
                  THEN snumber
               WHEN SID IS NULL
               AND snumber IS NULL
               AND unit IS NULL
               AND country IS NOT NULL
               AND state IS NOT NULL
                  THEN state
               WHEN SID IS NULL
               AND snumber IS NULL
               AND unit IS NOT NULL
               AND country IS NOT NULL
               AND state IS NOT NULL
                  THEN country
               WHEN SID IS NOT NULL
               AND snumber IS NULL
               AND unit IS NOT NULL
               AND country IS NULL
               AND state IS NOT NULL
                  THEN unit
               WHEN SID IS NULL
               AND snumber IS NOT NULL
               AND unit IS NULL
               AND country IS NOT NULL
               AND state IS NULL
                  THEN country
               WHEN SID IS NULL
               AND snumber IS NOT NULL
               AND unit IS NULL
               AND country IS NULL
               AND state IS NOT NULL
                  THEN state
               WHEN SID IS NOT NULL
               AND snumber IS NULL
               AND unit IS NOT NULL
               AND country IS NULL
               AND state IS NULL
                  THEN unit
               WHEN SID IS NOT NULL
               AND snumber IS NULL
               AND unit IS NULL
               AND country IS NOT NULL
               AND state IS NULL
                  THEN country
               WHEN SID IS NOT NULL
               AND snumber IS NULL
               AND unit IS NULL
               AND country IS NULL
               AND state IS NOT NULL
                  THEN state
               WHEN SID IS NULL
               AND snumber IS NOT NULL
               AND unit IS NOT NULL
               AND country IS NOT NULL
               AND state IS NULL
                  THEN snumber
               WHEN SID IS NULL
               AND snumber IS NULL
               AND unit IS NOT NULL
               AND country IS NOT NULL
               AND state IS NULL
                  THEN country
                  when sid is not null and snumber is null and unit is null and country is not null and state is not null then country
               ELSE NULL
            END
           ) snumber,
           (CASE
               WHEN SID IS NOT NULL
               AND snumber IS NOT NULL
               AND unit IS NULL
               AND country IS NOT NULL
               AND state IS NOT NULL
                  THEN country
               WHEN SID IS NOT NULL
               AND snumber IS NOT NULL
               AND unit IS NOT NULL
               AND country IS NULL
               AND state IS NOT NULL
                  THEN unit
               WHEN SID IS NULL AND snumber IS NOT NULL AND unit IS NOT NULL
                  THEN country
               WHEN SID IS NOT NULL
               AND snumber IS NULL
               AND unit IS NOT NULL
               AND country IS NOT NULL
               AND state IS NOT NULL
                  THEN country
               WHEN SID IS NOT NULL
               AND snumber IS NOT NULL
               AND unit IS NOT NULL
               AND country IS NOT NULL
               AND state IS NULL
                  THEN unit
               WHEN SID IS NOT NULL AND snumber IS NOT NULL AND unit IS NOT NULL
                  THEN unit
               WHEN SID IS NULL
               AND snumber IS NULL
               AND unit IS NOT NULL
               AND country IS NOT NULL
               AND state IS NOT NULL
                  THEN state
               WHEN SID IS NOT NULL
               AND snumber IS NULL
               AND unit IS NOT NULL
               AND country IS NULL
               AND state IS NOT NULL
                  THEN state
               WHEN SID IS NOT NULL
               AND snumber IS NOT NULL
               AND unit IS NULL
               AND country IS NULL
               AND state IS NOT NULL
                  THEN state
               WHEN SID IS NOT NULL
               AND snumber IS NOT NULL
               AND unit IS NULL
               AND country IS NOT NULL
               AND state IS NULL
                  THEN country
                  when sid is not null and snumber is null and unit is null and country is not null and state is not null then state
               ELSE NULL
            END
           ) unit,
           (CASE
               WHEN SID IS NOT NULL
               AND snumber IS NOT NULL
               AND unit IS NOT NULL
               AND country IS NULL
               AND state IS NOT NULL
                  THEN state
               WHEN SID IS NOT NULL
               AND snumber IS NOT NULL
               AND unit IS NOT NULL
               AND country IS NOT NULL
               AND state IS NULL
                  THEN country
               WHEN SID IS NOT NULL
               AND snumber IS NOT NULL
               AND unit IS NOT NULL
               AND country IS NOT NULL
                  THEN country
               WHEN SID IS NULL
               AND snumber IS NOT NULL
               AND unit IS NOT NULL
               AND country IS NOT NULL
               AND state IS NOT NULL
                  THEN state
               WHEN SID IS NOT NULL
               AND snumber IS NULL
               AND unit IS NOT NULL
               AND country IS NOT NULL
               AND state IS NOT NULL
                  THEN state
               WHEN SID IS NOT NULL
               AND snumber IS NOT NULL
               AND unit IS NULL
               AND country IS NOT NULL
               AND state IS NOT NULL
                  THEN state
               ELSE NULL
            END
           ) country,
           (CASE
               WHEN SID IS NOT NULL
               AND snumber IS NOT NULL
               AND unit IS NOT NULL
               AND country IS NOT NULL
               AND state IS NOT NULL
                  THEN state
               ELSE NULL
            END
           ) state
      FROM tablx;
    Cheers...

  • Problems sorting larger sets of XMLType columns/tables

    Hi,
    Here's something I tried to wrap my head around:
    I'm using Oracle 11g r1 for Windows Server 2003.
    I've imported a fairly large set of XML files into a temporary XMLType table. Now
    I want to sort the contents of the table and put them into another table which
    uses a sequence to get primary keys (would be a longer story to explain, basically
    sorting by this non-XML primary key is super-fast as opposed to everything else
    I've tried, plus I need something unique):
    INSERT INTO realtable SELECT 0, object_value
    FROM tmptable ORDER BY extractValue(object_value, '/some/*/field');It works fine for a very small number of rows but when I tried with about 30000 rows,
    still not too much, two kinds of things can happen. Either, Oracle gobbles up a huge amount
    of memory (>1,5GB) until the statement breaks:
    ORA-04030: Zu wenig Prozessspeicher fⁿr Versuch 33292 Bytes zuzuweisen
    (callheap,kllcqgf:kllsltba)Or I get something like this:
    ORA-00600: Interner Fehlercode, Argumente: [kqludp2], [0x1F31EC94], [0], [], [], [], [], []I haven't wasted too much time looking into this. I tried storage options clob and binary xml
    for tmptable. Clob seems to induce the latter problem and binary xml the former but I haven't
    made further experiments.
    I can create a workaround from outside Oracle I think, so it's not serious however I'd would
    be interesting to know what happened or if there is a better way to do this.
    Thanks!

    Unfortunately, the problems are not reproducible in a meaningful way. All I can say is that once a statement will result in a kqludp2, it will always fail with the exactly same error message until I reinstall the database from scratch. On the other
    side, when I found a configuration that works, I could delete and rebuild/refill a table multiple times without the thing ever breaking.
    As the most recent example, after the latest trouble I deleted the database and changed my DDL scripts to the last configuration I wanted to try and broke the last time (several tables with two normal columns and an XMLType column each), everything worked like a breeze.
    I can file a TAR when I get a support ID from my employer, however I installed the database on a virtual machine (I should have mentioned that earlier) and Oracle doesn't officially support that configuration from what I know so I'll doubt they'll do anything about it. I've procured a physical computer now and try to reproduce any of the problems when I get to it.

  • NamedQuery problem- single argument compared to multiple columns

    Hello,
    I'm not sure if this issue is a bug or if I'm misinterpreting the API. I'm trying to execute a text search query against multiple columns in the same table via EJB 3.0, e.g.
    select object(o) from Location o where o.city LIKE :searchString OR o.county LIKE :searchString"So, a single text argument is compared to multiple fields- but I keep getting an exception that the number of supplied arguments (one) does not match the number of required arguments (one- even though it's ID is referenced twice). Is there a separate syntax for repeating arguments in EQL (EJB 3.0, JDeveloper 10.1.3)? Is it not supported?
    I get around the issue by just specifying a Query at runtime, but I'd prefer --if possible-- to create a NamedQuery instead.
    Any help would be appreciated. Take care.

    Should the EJBQL statement be
    select object(o) from Location o where o.city LIKE :?1 OR o.county LIKE :?2

  • Help! Multiple Column Output

    Hi everyone. I'm hoping someone can help me work through this
    problem I'm having outputting data to multiple columns. I'm
    creating a photo gallery and I would like my table to look
    something like this: empty td, td with photo, empty td, td with
    photo, new row below those td's with a caption for the photo. I've
    taken tutorials online, but none of them explain how to have
    additional rows, or additional columns. Thanks in advance for any
    help!

    straffenp wrote:
    > Hi everyone. I'm hoping someone can help me work through
    this problem I'm
    > having outputting data to multiple columns. I'm creating
    a photo gallery and I
    > would like my table to look something like this: empty
    td, td with photo, empty
    > td, td with photo, new row below those td's with a
    caption for the photo. I've
    > taken tutorials online, but none of them explain how to
    have additional rows,
    > or additional columns. Thanks in advance for any help!
    >
    It is all a matter of figuring out what you want to output
    for each
    iteration and developing your logic accordingly. The tricky
    part I see
    with your requirement is that you will need to create two
    loops through
    each row of output you want, the first loop to create the top
    row and
    the second loop to create the bottom.

  • Multiple Column Sorting in iTunes

    I have seen many conversations around the edges of this, but no answers.  I am curious if it is possible to configure a custom sort in iTunes involving multiple columns. 
    Here is what I would like to end up with - Artist; Sort Show (where I have stored the release date); Album; Disk Number; Track Number.  Seeing my albums in chronological order is the way I always sorted physical albums, I would like to store my virtual ones the same way.  iTunes allows me to use Album by Artist and then sort by Sort Show, but this then displays the tracks in alphabetic order by name! 
    Identifying multiple sort columns (as in Excel) would be ideal.  Thanks for any help you can provide.
    Dave

    It is a database internally, and there are some multivalued sorts, but as users we don't get to specify custom sort orders. Album by Artist is more properly Album by Album Artist and in pseudo-SQL it would go something like this.
    SELECT * FROM Selection ORDER BY SortAlbumArtist, SortAlbum, Disc# , Track#
    Where there is no SortAlbumArtist it is inferred from the first non-empty value of AlbumArtist, SortArtist or Artist.
    Where there is no SortAlbum it is inferred from Album.
    The Disc# & Track# sorts place empties last.
    Presumably the designers think they've included useful options and adding nested sorting features would be too complicated, but you can make suggestions via iTunes Feedback.
    tt2

  • Multiple columns within a single text frame

    Is it at all possible to make a single text frame containing first a single column followed by two columns?
    Why: I need to have my heading expanding across my two column body text. What's important is that I need the two column body text to automatically drop whenever I type (or paste) in more text in my heading. Like it would if the heading and body text was in a single column.
    My text frame options (I work in CS3) do not give me this option, I can only work in one "frame set". I have tried fixing this problem with combinations of tables, multiple text frames and text wrap, but nothing really works.

    Thank you Peter.
    Yes I did try it.
    InDesign CS3 just gives me this alert:
    I also tryed copying the files (HeadStraddler.jsx and HeadStraddler.indl) into a folder like you suggested.
    C:\Program Files\Adobe\Adobe InDesign CS3\Scripts\Scripts Panel\Version 4.0 Scripts\HeadStraddlerForCS2.
    But I just get the same alert.

  • I am unable to sort multiple columns in a table created in Pages.

    I had been using Appleworks up until I installed Lion and have now switched to iWork. I created a table within a Pages document and am able to sort a single column (using the Table Inspector and choosing Sort from  Edit Rows and Columns) but the Sort option is grayed out when I attempt to sort multiple columns.
    In another post, someone talked about this being a problem if you have merged fields. I do not believe I have done this (to be honest I don't know the function of merging fields).
    This is very frustrating as I was easily able to sort these tables in Appleworks.

    Sharon Anderson wrote:
    Thanks for your quick response! I have been trying that but then found that Numbers would only let me print in landscape view so I had to paste the table back into Pages. Is there a way to print in portrat view (from Numbers?)
    Not so. In the lower left corner of the window, there's an icon that looks like a piece of paper. If you see this:
    you are in Sheet View, or normal, mode. If you see this:
    You are in Print View mode. Now you see the icons for portrait and landscape modes. Click your choice. Then arrange your content to fit the pages as you wish.
    Jerry

  • Sort functionality using MULTIPLE columns in a table control

    Hi all,
    I have a custom screen with table control.Now i need to provide SORT functinality in this screen for the columns in the table control.
    My questins:
    1.Is it possible to seelct MULTIPLE columns in a table control for SORTING?If yes,what explicit settings do i need to do while creatng the TABEL CONTROL in the screen?DO I need to select "Column selection " as MULTIPLE??
    2.How do I write the code for SORT functinonality for multiple columns?
    I know how to write the code for SORTING on basis of single column .
    Thanks!

    Hi Rob,
    Thanks for the reply.
    However I was thinking to apply the same logic as for single columns as follows:
    types : begin of ty_fields,
                c_fieldname(20),
               end of ty_fields.
    data  : t_fields type table of ty_fields,
               wa_fields like line of t_fields.
    WHEN 'SORTUP'.(Ascending)
          loop at TABLE tc01-cols INTO wa_tc01  where  selected = 'X'.
          SPLIT wa_tc01-screen-name AT '-' INTO g_help g_fieldname.
          wa_fields-c_fieldname = g_fieldname.
          append wa_fields to t_fields.
          endloop.
          describe table t_fields lines l_index.
          c_count = 1.
          if c_count  <= l_index.
          read table t_fields into wa_fields index c_count.
          case c_count.
          when '1'.
          l_field1 = wa_fields-c_fieldname.
          when '2'.
         l_field2 = wa_fields-c_fieldname.
        and so on depending on the no of columns in the table control...
          endcase.
          endif.
          SORT t_tvbdpl_scr BY  l_fields1 l_fields 2......l_fieldn.
    Let me know if the above method will work!Also for the above method to work will the type of fields(columns on whihc sort function will be applied) matter???
    Thanks again for your time.

  • Problem with Column Sorting in Request Table View

    We've enabled column sorting on the table view in an Answers request but it doesn't work when more than around 400 rows are returned. It works Ok when fewer than 400 rows are returned. Does anyone know if there is a specific limit to the number of rows where column sorting works?
    Thanks,
    Mike

    I've dug into the query log a little more. When this request returns more than around 400 records and you click on a column heading to sort the table view, the query from the log is not changing to reflect the new sort order. It stays as whatever the default sort order was for the request.
    Column heading sorting on other requests in different subject areas on this same server works fine. I've tested this other request with up to 6400 rows returning and it's sorting works.
    All caching is turned off for the subject area.

  • Multiple columns from a query sorted vertically

    Is it possible to sort a query resultset vertically, with
    multiple columns across the page, in the following manner, with
    page breaks after 40 rows? I can get it to sort horizontally just
    fine with tables, but how can it be done vertically as shown?
    JONES, Abby JONES, Betty JONES, Dawn JONES, Frank
    JONES, Adam JONES, Bill JONES, Debbie JONES, Gayle
    JONES, Alice JONES, Bob JONES, Denton JONES, Henry
    JONES, Ben JONES, Cathy JONES, Emma JONES, John

    This will get you started. I assume you had the appropriate
    order by clause in your query. I also assume you want 4 columns per
    line.
    My approach would be to convert the query to an array and
    then output the array.
    columns = 4;
    maxrows = 40;
    recordsperpage = columns * rows;
    records = query.recordcount;
    myArray = ArrayNew(2);
    ThisColumn = 1;
    ThisRow = 1;
    if (records gt recordsperpage)
    LoopTill = recordsperpage;
    else
    LoopTill = records;
    for ( ii = 1; ii lte LoopTill; ii = ii + 1){
    myArray[ThisRow][ThisColumn] = query.field[ii];
    increment ThisRow;
    if (ThisRow = MaxRows + 1) {
    ThisRow = 1;
    increment ThisColumn;
    } // if
    } // looop
    You can do the rest

  • How to Sort Multiple Column In ALV_LIST_DISPLAY

    Dear Experts,
                         Recently i've facing a problem to Sort multiple Column in ALV_LIST_DISPLAY.Whenever i need to sort 4 columns at a time , only 3 was sorted not the 4'th one.But i have already clearly mentioned in my sort section .Can anybody help me overcome this problem?
    warm regards,
    sameek mazumder.

    Hi samgpi,
    You should have no prolem with doing such sorting by using the parameter IT_SORT, available when using class or FM...
    Can you paste you sort section here so we can have a closer look?
    Kr,
    Manu.

  • Sorting a Collection with dynamic columns using a custom compare function for multiple columns

    I need help and ideas on how to sort a ListCollectionView.  My problem is complicated by 3 requirements-
         1. The column values contain HTML tags that needs to be removed before sorting (use custom compareFunction to strip HTML)
         2. The columns are dynamic, so dataField names are not known at compile time (need a single compareFunction for all columns)
         3. The data is used in an AdvancedDataGrid so multi-column sorting is required
    I have figured out how to solve any 2 of the 3 requirements.  However, I am having difficulties supporting all 3 requirements.
    Any help or ideas would be greatly appreciated.  Thanks.

    After playing with this some more I think I've figured out a solution.  This seems to work in initial testing.  Also, there is not a need to capture the current sort column in the headerRelease event which many offered solutions suggested.  Another benefit to this solution is that keyboard initiated sorting is handled also.  Whereas the headerRelease event is only triggered by a mouse click on the column header and special handling is required if the user uses the keyboard to access the column header.
    One point that I don't understand is how ascending/decending order is determined.  Behavior seems to be different between a single SortField versus multiple SortFields.  Notice how the compareResults are handled for the different situations.  Anyone out there know why???
     private function colSortCompareFunction(obj1:Object, obj2:Object, fields:Array = null):int{
         var compareResults:int = 0; 
         var newObj1:Object = new Object(); 
         var newObj2:Object = new Object();
          // should not be a condition that is met   
         if (_dataProviderDetails.sort.fields == null)     {
              var s:Sort = new Sort(); 
              var f:Function = s.compareFunction; 
              return f.call(null, obj1, obj2, fields);     }
         // when a single column is selected for sorting   
         else if (_dataProviderDetails.sort.fields.length == 1)     {
              var firstFld:SortField = _dataProviderDetails.sort.fields[0];
              newObj1[firstFld.name] = stripHTML(obj1[firstFld.name]as String);          newObj2[firstFld.name] = stripHTML(obj2[firstFld.name]
    as String);
              compareResults = ObjectUtil.compare(newObj1[firstFld.name], newObj2[firstFld.name]);
               return compareResults;     }
         // when multiple columns are selected for sorting   
         else       {
              for each (var fld:SortField in _dataProviderDetails.sort.fields)          {
                   newObj1[fld.name] = stripHTML(obj1[fld.name]
    as String);               newObj2[fld.name] = stripHTML(obj2[fld.name]
    as String);
                   compareResults = ObjectUtil.compare(newObj1[fld.name], newObj2[fld.name]);
                    if (compareResults != 0)               {
                        if (fld.descending)                    {
                             return compareResults * -1;                    }
                        else                      {
                             return compareResults;                    }
               return compareResults;     }
    Does anyone see any problems with this solution?
    NOTE:  stripHTML(String) is a simple function using regular expression to remove HTML tags.
    Thx

  • How do you count the multiple columns of a field in a table

    How do you count the multiple columns of a field in a table

    Hi,
    4396bf34-e890-4202-a6b0-4e08c9ff0e89 wrote:
    How do you count the multiple columns of a field in a table
    Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002
    "Field" isn't a standard database term.  Some people say "field" when they mean "column", but I don't think that's what you mean ("How do you count the multiple columns of a column ..").  Do you want to know how many times a column is used (as opposed to NULL), or the number of different values in a column?  You really need to show what you want.

  • Multiple column sorting.

    How does one sort multiple columns( date, String, time etc...). I want to sort by date where two dates can be alike as well. I could use HashMap for that reason.
    Please help.
    Thanks in advance.

    Hi,
    A demo of the comparator class is given below. I've tried to put it into the table class.
    import java.util.*;
    import javax.swing.*;
    import java.awt.BorderLayout;
    import java.awt.event.*;
    import javax.swing.table.*;
    import javax.swing.event.*;
    class MultipleColumnSortTest
         MultipleColumnSortTest()
              JFrame frame = new JFrame("MultipleColumnSortTest");
              frame.setBounds(10,10,750,550);
              Vector fieldNames = new Vector();
              fieldNames.add("Dates");
              fieldNames.add("Strings");
              Vector dataVector = new Vector();
              for(int i = 0; i < 5; ++ i)
                   Vector row = new Vector();
                   row.add(new Date());
                   row.add("abc" + i%2);
                   dataVector.add(row);
              final SortableDataVector tableModel = new SortableDataVector(dataVector,fieldNames);
              int [] sortIndices = new int[2];
              sortIndices [0] = 0 ;
              sortIndices [1] = 1 ;
              tableModel.setSortPriority(sortIndices);
              JTable table = new JTable(tableModel);
              JScrollPane scrollpane = new JScrollPane(table);
              frame.getContentPane().add(scrollpane);
              JButton button = new JButton("Sort Data");
              frame.getContentPane().add(button,BorderLayout.SOUTH);
              button.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent event)
                        tableModel.setAscendingOrder(!tableModel.isAscendingOrder());
                        tableModel.sort();
              frame.setVisible(true);
         public static void main(String [] args)
              MultipleColumnSortTest appln = new MultipleColumnSortTest();
    class SortableDataVector extends DefaultTableModel implements Comparator
         private int [] indices;
         private boolean isAscendingOrder;
         public SortableDataVector(Vector dataVector, Vector fieldNames)
              super(dataVector,fieldNames);
              setAscendingOrder(true);
         public void setAscendingOrder(boolean b)
              isAscendingOrder = b;
         public boolean isAscendingOrder()
              return isAscendingOrder;
         public void setSortPriority(int [] indices)
              this.indices = indices;
         public int compare(Object o1,Object o2)
              int comparisonResult = compareAscending(o1,o2);
              if(!isAscendingOrder)
                   if(comparisonResult < 0)
                        comparisonResult = 1;
                   else if (comparisonResult > 0)
                        comparisonResult = -1;               
              return comparisonResult;
         private int compareAscending(Object o1, Object o2)
              int comparisonResult = 0;
              if((o1 == null)&&(o2 != null))
                   comparisonResult = -1;
              else if((o1 != null)&&(o2 == null))
                   comparisonResult = 1;
              else if((o1 != null)&&(o2 != null))
                   List firstRow = (List)o1;
                   List secondRow = (List)o2;
                   for(int i = 0; ((i < indices.length)&&(comparisonResult == 0)); ++i)
                        if(indices[i] < firstRow.size())
                             comparisonResult =
                                  DatatypeSensitiveComparator.compare(
                                       firstRow.get(indices),
                                       secondRow.get(indices[i]));
              return comparisonResult;
         public boolean equals(Object obj)
              if(obj == null)
                   return false;
              return this.equals(obj);
         public void sort()
              if((indices != null)&&(indices.length > 0))
                   Collections.sort(dataVector,this);
                   fireTableChanged(new TableModelEvent(this));
    class DatatypeSensitiveComparator
         public static int compare(Object firstValue, Object secondValue)
              int comparisonResult = 0;
              if((firstValue != null)&&(secondValue == null))
                   comparisonResult = 1;
              else if((firstValue == null)&&(secondValue != null))
                   comparisonResult = -1;
              else if((firstValue != null)&&(secondValue != null))
                   Class clazz = firstValue.getClass();
                   if(!clazz.equals(secondValue.getClass()))
                        throw new IllegalArgumentException("Class are not the same ->"
                             + clazz.getName() + ":" +
                             secondValue.getClass().getName());
                   if(clazz.equals(String.class))
                        comparisonResult = ((String)firstValue)
                             .compareTo(((String)secondValue));
                   else if(clazz.equals(Date.class))
                        comparisonResult = ((Date)firstValue)
                             .compareTo(((Date)secondValue));
              return comparisonResult;

Maybe you are looking for

  • Renaming columns in 8i

    I have tried in vain to rename a column in 8i. There are no good examples out there. Here's my code SQL> DESC KKQA_CLINIC_CD Name Null? Type CLINIC_CD NOT NULL VARCHAR2(15) REC_EFFENDDT NOT NULL DATE REC_EFFDT NOT NULL DATE IDX_NM VARCHAR2(60) DEPT V

  • Used Smarttalk in the USA

    Have used the smarttalk in the USA whilst on holiday Save me loads of money. Quality of talk was great. Setup ok once I had got though the Hotel Wifi setup. worked first time when I went into a McDonnell's with there free wifi. even got the yanks tal

  • How to make itunes account for free

    how to make itunes account for free?

  • Material Determinatio...

    Hi, Can anyone tell me then material determination process.I have scenario for one of our client it is as follows, Customer orders Material X from vendor.Vendor has materials which technically same as X,but some other materials. Customer has X,XY & X

  • Album page is skipped on Ipod

    Hey, I have a 60gb video ipod and I've had this problem ever since I bought it. If I have one album by an artist along with some other songs, with no album tag, the ipod will skip the album page when I select the artist, and go right to the song list