Sort by multiple columns

I'm hoping that I'm missing something really obvious here and someone can kindly sort me out.
I've got loads of comp albums. In fact the vast majority of my library is mix CDs from various clubs/DJs/etc. Previously I had the lib sorted by artist and just set the artist for every track on each album to what ever the publisher was e.g Ministry of Sound or Global Underground. This kept everything nice and tidy.
The album artist field then comes along so while re-encoding my CDs to lossless I thought I'd name each track correctly and use this. All fine and sorted by album artist. Trouble is now the default sort when you do this is:
album artist -> artist
i.e. within the scope of 1 album artist all the entries are mixed up between the multiple albums and track orders are all over the place. What I'd really like is simple to set the sort on my lib to:
album artist -> album -> track number
I know it could be a little tidier to sort just by album but that annoys the **** outta me and I really don't want to have to create 1000s of playlists.

Try sorting on Album until the header indicates "Album by Artist". See if that looks better ...

Similar Messages

  • How to sort on Multiple columns in WebI report

    Hi
             I am working in BO XI R2. I have a report containing two columns in a section. Section is on Fiscal Year- Fiscal year includes calendar year 2010 and 2011.
    data for fiscal year 2010 is from october onwards.
    The two columns in the section are
    column 1- calendar  Year
    column 2- calendar Month
    I want to display results as follows
    2010 oct
    2010 nov
    2010 dec
    2011 jan
    2011 feb and so on.
    I first sorted calendar year column so that it shows
    2010
    2011
    but when i try to sort calendar month, for 2010 I am able to display oct, nov, dec in a ascending order but for 2011 the months are displayed randomly. Business user wants to see them in ascending order from Jan to June.
    Please let me know how to get this functionality in the report.
    Thanks in advance.

    Hello Gurus,
    I have same issue with me I am working on XI3.1 and I want to apply Sort on multiple columns on Single block.
    So as you can see the "Org Name" is decending Order and " Emails Sent" total is 63 and   "BCB" have 18 total.
    How would I apply sorting based on email sent from high number to low number. Please help.
    Thank you.
    Adil
    Org Name
    Org Tax ID
    Org ID
    Email
    Emails Sent
    Undelivered Emails
    Well Shot
    11111111
    22222222
    [email protected]
    32
    0
    11111111
    22222222
    [email protected]
    12
    0
    11111111
    22222222
    [email protected]
    10
    0
    11111111
    22222222
    [email protected]
    9
    0
    Well Shot
    Subtotal:
    63
    0
    Org Name
    Org Tax ID
    Org ID
    Email
    Emails Sent
    Undelivered Emails
    Well Play
    444444444
    33333333
    [email protected]
    1
    0
    WellPoint KY Test Org - Central
    Subtotal:
    1
    0
    Org Name
    Org Tax ID
    Org ID
    Email
    Emails Sent
    Undelivered Emails
    BCB
    55555555
    99999999
    [email protected]
    8
    0
    55555555
    99999999
    [email protected]
    8
    0
    55555555
    99999999
    [email protected]
    2
    0
    BCB
    Subtotal:
    18
    0
    Org Name
    Org Tax ID
    Org ID
    Email
    Emails Sent
    Undelivered Emails
    Ghazi, Foundation
    77777777
    8888888
    [email protected]
    1
    0
    77777777
    8888888
    [email protected]
    1
    0
    77777777
    8888888
    [email protected]
    1
    0
    77777777
    8888888
    [email protected]
    1
    0
    77777777
    8888888
    [email protected]
    1
    0
    Ghazi, Foundation
    Subtotal:
    5
    0
    Availity Orgnaization Name
    Org Tax ID
    Org ID
    Email
    Number of Emails Sent
    Undelivered Emails
    Ghazi, Foundations
    66666666
    1234567893
    [email protected]
    1
    0
    66666666
    1234567893
    [email protected]
    1
    0
    Ghazi,  Foundations
    Subtotal:
    2
    0
    Totals:
    89
    0

  • We used to be able to sort by multiple columns/rows at once by right clicking on the header and choosing show more options-how do we do that in the new Numbers?

    We used to be able to sort by multiple columns/rows at once by right clicking on the header and choosing show more options-how do we do that in the new Numbers?  It doesn't appear anywhere.  Do I now have to sort massive tables by each column one at a time now?  Also there used to be an easier way to merge/unmerge cells without me having to go to the table menu each time.  Am I missing something?

    Multiple column sort is a missing feature in the new version.  Hopefully soon to return. You can do a multicolumn sort by sorting one at a time in reverse order of importance.
    For merging and unmerging cells, I select the cells and right click to bring up the contextual menu. Merge and unmerge are on the menu.  You could also create keyboard shortcuts for Merge Cells and Unmerge Cells in the Table menu.

  • Sorting by Multiple Columns in Numbers 3.0

    The new Numbers 3.0 update has moved some stuff around I need, and can not find. 
    Where is "Reorganize"?  The ability to sort multiple by columns.  (e.g. Sort Ascending Column A, THEN Column B, THEN Column C)
    mf

    this didn't work for me - i have item, then price, then checkbox. using the formula just gave an amalgamation of the three cells.
    Hi Saqib,
    The very idea of the workaround is to give an amalgamation, more often called "concatenation", and then just sort on the column containing the concatenated "string."
    As you've discovered, the =A&C&B formula only works if A,C, and B are all text. If you've got numbers in the mix then you have to pad them with leading zeros for them to sort as you want. That's easily done.
    Let's say C is a number and A and B are strings. You could put somethng like this in column D:
    =A&RIGHT("0000"&C,4)&B
    It's certainly not convenient to have to add a new column and put in a formula. But this is not *that* difficult as a workaround until the day multcolumn sort is added back in.
    SG

  • Can data be sorted by multiple columns in numbers version 3

    Since upgrading Numbers to version 3 (now 3.0.1) I have been unable to sort data in spreadsheets using multiple columns.  Anyone found a solution?
    Regards
    kurrajong60

    Here's a simple example. Say you want this sorted first by Region then by Name then by Amount.
    So if you set up a sort index column with a simple formula and all you have to do is this (two clicks):
    Giving you this:
    Of course you could do it as I think Hiroto is suggesting and manually sort first by column B, then sort by C, then sort by A.
    But that's a lot of trouble and it's easy to confuse the order so you end up having to start over again.
    SG

  • User need to have the ability to sort on Multiple columns

    Hi,
    I have one report on Dashboard, for that report user want to sort all columns at a time. But  i am not find any option to set like this.
    Right now i am able to sort only one column at time, Please let me know is there any option like this.
    Thanks in advance.
    Ramana

    Hi Ramana,
    This we cannot acheive in Analytics,You can do this in RPD BMM
    Below the url for more info,
    http://oraclebizint.wordpress.com/2008/04/28/oracle-bi-ee-101332-handling-sort-order-in-hyperion-essbase-931-evaluate-and-mdx/
    Mark if helps,
    Thanks,

  • ALV: How to sort multiple columns?

    Hi all,
    Good morning!
    I have a requirement to sort multiple columns in ALV. I did a search and tried with following codes:
    data: lo_config_alv  type ref to cl_salv_wd_config_table.
    lo_config_alv->if_salv_wd_table_settings~set_multi_column_sort( value = abap_true ).
    But I still can not sort for multiple columns.
    Please guide me how to do that.
    Thanks,
    Khanh

    Hello,
    If you want to sort ALV by multiple fields, then you have to create sort rule for each field and set sort position for each field to specify the sequence in which you want to sort multiple columns.
    Here is a sample code:
    * Sort rows by PRICE descending
      DATA: lr_field1 TYPE REF TO cl_salv_wd_field.
      DATA: lr_rule1 TYPE REF TO CL_SALV_WD_SORT_RULE.
      lr_field1 = lv_value->if_salv_wd_field_settings~get_field( 'PRICE' ).
      lr_field1->if_salv_wd_sort~create_sort_rule( EXPORTING sort_order = if_salv_wd_c_sort=>sort_order_descending
                                                   RECEIVING value = lr_rule1 ).
      lr_rule1->set_sort_position(  2 ). "set the sort position to 2
    * Sort rows by seatsmax descending
      DATA: lr_field2 TYPE REF TO cl_salv_wd_field.
      DATA: lr_rule2 TYPE REF TO CL_SALV_WD_SORT_RULE.
      lr_field2 = lv_value->if_salv_wd_field_settings~get_field( 'SEATSMAX' ).
      lr_field2->if_salv_wd_sort~create_sort_rule( EXPORTING sort_order = if_salv_wd_c_sort=>sort_order_descending
                                                              RECEIVING value = lr_rule2 ).
      lr_rule2->set_sort_position( 1 ). "set the sort position to 1
    * Sort rows by seatsocc descending
      DATA: lr_field TYPE REF TO cl_salv_wd_field.
      DATA: lr_rule3 TYPE REF TO CL_SALV_WD_SORT_RULE.
      lr_field = lv_value->if_salv_wd_field_settings~get_field( 'SEATSOCC' ).
      lr_field->if_salv_wd_sort~create_sort_rule( EXPORTING sort_order = if_salv_wd_c_sort=>sort_order_descending
      RECEIVING value = lr_rule3 ).
      lr_rule3->set_sort_position( 3 ). "set the sort position to 3
    In the above code, the sequence of sorting would be seatsmax price seatsocc
    If you dont specify the sort position, then the sequence of sorting would be the order in which the sort rules are created.
    In the above example, if we didnt set sort positions for the fields, then order would be price seatsmax seatsocc.
    Refer to this link for more info: https://cw.sdn.sap.com/cw/docs/DOC-33859
    Hope this helps!
    Regards,
    Srilatha

  • Is it possible to do sorting on multiple field inside a GROUP

    Hi
    I am wondering if it is possible to do a multiple sorting on multiple column/fields?
    When I right click on Change Group on the report
    on the "Change Group Options" window, it only has one field which allow you to sort in ascending/ descending order.
    I notice that it also has another checkbox which called Use a formula as Group Sort order, I am not quite sure how to use it to sort multifield/column.
    E.g.
    I have a table which has 5 fields
    I would like to sort it by TotalSpend, TotalEarned, Department, ...etc
    I would be grateful, if you can show me how to do a group sorting for multi column/fields
    Thanks in advance.

    To Sastry,
    Thanks for your information, unfortunately, I am using Crystal report XI.
    To Sandra,
    <<Yes, go into the Group expert and select them in the order in which you want them sorted>>
    Do you mean create different group to do the sorting?
    Could you show me how to create a formula which allow crystal report to do the sorting on multi-field.
    Thanks in advance.

  • 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

  • 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

  • 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...

  • 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

  • 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;

  • Sorting multiple columns at a time

    Hi All,
    I have requirement which is web dynpro table loading with the data i need to sort the three columns
    at a time. initially this sorted data is coming from Function module, but now the data is coming from BW to Web dynpro java
    I have one method in sort class which will sort the table on one column at time. i need help in enhancing this method to work for three columns.
      public void sort(String columnId, IWDNode dataSource) {
           IWDTableColumn column =
                (IWDTableColumn) table.getView().getElement(columnId);
           ReversableComparator reversable =
                (ReversableComparator) comparatorForColumn.get(column);
           if (reversable == null)
                return; // not a sortable column
           // remove icon of previously sorted column
           if (currentlySortedColumn != null
                && currentlySortedColumn.getHeader() != null)
                currentlySortedColumn.getHeader().setImageSource(null);
           // bookkeeping
           if (column == currentlySortedColumn) {
                //               reversable.toggleReversed();
           currentlySortedColumn = column;
           // set icon in currently sorted column
           /*if (currentlySortedColumn.getHeader() != null)
                currentlySortedColumn.getHeader().setImageSource(
                     reversable.isReversed()
                          ? "~sapicons/s_b_srtd.GIF"
                          : "~sapicons/s_b_srtu.GIF");
           // sorting
           dataSource.sortElements(reversable);
    Regards,
    Lakshmi Kodavati

    Hi all,
    The solution for EP6.40 Multiple column sorter
    Class file:
    http://wiki.sdn.sap.com/wiki/display/Snippets/Tablesorterbymultiplecolumns%28WebDynproJava%29
    f you does not have WDTableColumnSortDirection try to modify the MultiAttributesNodeComparator and replace WDTableColumnSortDirection with the boolean flag-indicator of the sorting direction. Like this:
    boolean sortAsc = true;  // WDTableColumnSortDirection.UP
    Call this class from web dynpro view
    final MultiAttributesNodeComparator nodeComparator = new MultiAttributesNodeComparator();
                        nodeComparator.sortElements(new String[] {"InvoiceDate","Invoice","Contract"}, true, wdContext.nodeInvoiceListTable());
    Thanks for Siarhei_Pisarenka
    Edited by: narayana on Mar 25, 2010 10:02 AM
    Edited by: narayana on Mar 25, 2010 10:05 AM

Maybe you are looking for

  • Urgent help importing an XML file

    Hi all, I'm currently exporting my XML files from Magento, the webshop client. However I cannot use the XML task in ETL because I get the error about namedspaces. I can open the XML file itself no problem, it contains a few columns with data, some em

  • My HDD is not right

    Hi Apple, I'm using Macbook Air mid 2013, when i check about macbook in  the storage sheet i got like attached, i don't know what's problem with my mac. Please help me. Thanks

  • IPad mini backlight issues after digitizer replacement

    I recently replaced the digitizer on my 1st gen iPad mini, and after reassembly, I'm havering issues with the backlight. Please have a look at my photo and let me know what the issue may be. Thanks a lot, Dave

  • Going beyond 70+ hr DVR record time?

    The Motorola DVR that the FIOS tech installed, can only handle about 70 hrs of material.  Since I'm used to recording closer to 80 hrs, is there another option?  VCR compatible w. FIOS?  What about extended the hard drive, by plugging an external har

  • Format changes from one computer to another.....how come?

    Just bought a new laptop.......I have been doing all my editing on the computer at home without a problem......all clips are saved in MPEG and everything works fine.....(ultimately posting them all on YouTube).  As I needed to get a new laptop anyway