Sort an array of Application Class with respect to property

class MyClass
property string myProgram;
property string myType;
property string Description;
end-class;
Local array of MyClass &myProgArray;
&myProgArray.Sort("D");
I want to sort the Array in descending Order with respect to "myType".
How to provide "myType" parameter to sort method ?
Edited by: Mohsin on Oct 11, 2012 3:28 PM

If you add myType to the array then you can sort on that, assuming you have different values for myType.
According to PeopleBooks (8.51), API documentation;
Sort(order)
Note. This method works with arrays that have only one or two dimensions. You receive a runtime error if you try to use this method with an array that has more than two dimensions.

Similar Messages

  • Can't generate setters for array or collection classes with JAXB

    I am trying to use JAXB to generate the required setters for Spring beans. Although according to the book Java & XML Data Binding
    Chapter 3 page 42 by Brett McLaughlin it was possible with DTD's using
    <?xml version="1.0"?>
    <xml-java-binding-schema version="1.0-ea">
    <options package="javajaxb.generated.movies" default-reference-collection-type="array" />
    <element name="movies" type="class" root="true"/>
    </xml-java-binding-schema>
    to generate an array as in
    public Movie[] getMovie( ) {
    // implementation
    public void setMovie(Movie[] _Movie) {
    it doesn't look like that capability exists with JAXB 2.0 and XML Schemas. In their wisdom they just generate getters on Lists and tell you:
    <p>
    * This accessor method returns a reference to the live list,
    * not a snapshot. Therefore any modification you make to the
    * returned list will be present inside the JAXB object.
    * This is why there is not a <CODE>set</CODE> method for the filingForm property.
    * <p>
    * For example, to add a new item, do as follows:
    * <pre>
    * getFilingForm().add(newItem);
    * </pre>
    Of course this doesn't work for Spring injection where setters are needed.
    Does anyone know different or is there a way of getting around this ?
    I've tried constructor injection in Spring but it's not as convenient and involves extensive coding of generated code (not nice).
    Edited by: user3806112 on Mar 15, 2011 11:13 AM

    Oh I found it on this post
    http://cxf.547215.n5.nabble.com/NPE-in-generated-setter-method-when-collectionType-quot-indexed-quot-and-a-null-array-is-used-td3323012.html
    collectionType="indexed" in the globalBindings-tag
    it works in schema internal global bindings as well
    <jaxb:globalBindings collectionType="indexed" >

  • A  classpath error while  importing a class with @page import property

    Hi ,
    I am using Tomcat contaniner for jsp applications. I have developed a page that i have import a class. when i use
    <%@ page import="myclass" &>
    i got an error that myclass not found. I have placed into tomcat\webapps\myproject\web-inf\classes directory. So How will I set the classpath for myclass to work?
    thanks.

    I was able to simulate your problem when I created a mismatch in the case of the name of the class.
    for example if my program is called MyClass.java
    and in the import I do <@page import="myclass" %>
    Are you sure about the case of class name that you are using? Please check that the file is called myclass.java the class defined inside it is called myclass and the class file that is copied into the WEB-INF/classes directory is also myclass.class. There should be no difference in the case of the names. like MyClass.java or MyclaSS.class
    Other things to check are
    1. If myclass is defined in a package then you have to import with the package.
    2. Make sure that your jsp is located in the myprojects directory and the class file is copied under myprojects/WEB-INF/classes.
    Let me know if things still don't work
    regards,
    Abhishek.

  • Possible loss of precision - sorting 3 arrays respectively

    I have the following 2 arrays which need to be sorted according to a high-to-low sorted float array called avg. So float avg[5] is sorted high-to-low, and then String names[] is sorted respectively, for instance, before the sort, names[3]="Marty" and avg[3]=75, and after the sort 75 was in avg[0] because it was the highest, now Marty needs to be in names[0]. The same is with the int scores[5][8] array, the 5 rows need to be sorted corresponding to the new sorted avg array. Anyways here are the arrays and the sorting code i have. I get the error "possible loss of precision." Also the code tag on the forums isnt working for some reason.
    Arrays:
    float avg[]=new float[5];
    int temp[] = {34, 24, 78, 65, 45, 100, 90, 97, 56, 89, 78, 98, 74, 90, 98, 24, 45, 76, 89, 54, 12, 20, 22, 55, 66};
    String names[] = {"Mary","John","William","Debbie","Ralph"};
    int scores[][]= new int[5][8];
    for(a=0;a<=4;a++)
    for(b=0;b<=4;b++,c++)
    scores[a] = temp[c];
    Sort:
    public float sort(int[][] scores,String[] names, float avg[])
    int g,r,c,d,e;
    String q;
    for (r=0;r<=3;r++)
    for (g=r+1;g<=4;g++)
    if (avg[r]<avg[g])
    c=avg[r];
    avg[r]=avg[g];
    avg[g]=c;
    q=names[r];
    names[r]=names[g];
    names[g]=q;
    for(d=0;d<8;d++)
    e=scores[r][d];
    scores[r][d]=scores[g][d];
    scores[g][d]=e;

    The first time I got that error I misread it and got very excited: "possible lots of precision."
    Any way, you should point out the line where this occurs:
    c=avg[r];Here, c is an int and avg[r] a float. When you assign a float to an int, you loose
    the factional data, and as well, float have hold larger values than int. Why not make c a float?

  • Basic questions with respect to ABAP WebDynpro Application

    Hi All,
    I have two basic questions with respect to an ABAP WebDynpro application :
    a) If an ABAP WebDynpro application has been developed, how could it be made available to the end user?
    b) Can an ABAP WebDynpro application be developed in ECC or is it only applicable for version 4.6c?
    Thanks & Regards,
    Sushanth Hulkod

    Sushanth Hulkod wrote:
    > a) If an ABAP WebDynpro application has been developed, how could it be made available to the end user?
    >
    > b) Can an ABAP WebDynpro application be developed in ECC or is it only applicable for version 4.6c?
    a) If an ABAP WebDynpro application has been developed, how could it be made available to the end user?
    Answer - By providing direct link of the WD application created in SE80, creating iView for webdynpro abap application in the portal environment and  NWBC environment
    b) Can an ABAP WebDynpro application be developed in ECC or is it only applicable for version 4.6c?
    Answer - Yes it can be developed in ECC. Webdynpro ABAP is introduced in NW 2004s (SAP NetWeaver 7.0 or ECC 6.0)
    Thanks,
    Chandra

  • A question with respect to using RSL in an Application

    Hi
    This question is with respect to using RSL in an Application
    we are deciding to use RSL in our Application for improving the performance .  Before using them i am having some queries ,please share your ideas on these questions :
    Please let me know
    How can i decide what swc file is suited for my Application ??
    How many types of swc files are there what is the default swc file ??
    and how can i choose my swc suited for my Application ??
    Waiting for your replies .
    Thanks in advance .

    The SWCs you reference on the RSL options for MXMLC must match the ones that
    will be used as RSLs

  • Sort an array with two fields

    i have an array with three fields: id, name and date.
    i want to sort it by name first and then date.
    the size of my array could be as large as 1 million.
    what could be the most efficient way to do so?
    tia!

    It's very inefficient to sort an array on "the fly".
    In that case at least use a linked list so you don't
    have to move all elements after the insertion point to
    make room for a new insert. But it's much better to
    sort afterwards when all elements are in the array.Use a TreeSet. A linked list will be slower than a TreeSet, I suspect.
    I believe that with a TreeSet, insertions will be somewhat slower (O(logN) vs O(c)), but the subsequent sorting of a linked list will be, what, at least O(NlogN) and possibly O(N^2)? And when you're inserting the first elements into the TreeSet, it should be closer to O(c) anyway, whereas the after-the-fact sorting of a LinkedList wouldn't have an advantage like that.
    Then if necessary extract an array out of the TreeSet when you're done creating/inserting elements.
    But really, use a database.

  • Sorting an array of numbers with loops

    Hi, i'm looking for a way to sort an array or numbers with loops.
    my array looks like this. int[] numbers = {5,2,7,9,1}
    i know how to use the "sort" method and i want to do it without the sort method, but i am not very clear on the logic behind it.
    by the end it should look like this, {1,2,5,7,9}
    i know 2 loops are used, can you please give me a logic to work with.
    i have started the loops but what to do inside???
    int temp;
    for (int i=0; i<numbers.length; i++){
    for (int j=1; j<numbers; j++){
    if (numbers<numbers[j])
    temp = numbers[i];
    Any suggestions i will be thankful for.
    thank you.

    fly wrote:
    no not really a homework question.. i want to improve my logic because it is very poor at the moment.. but i'm sure someone knows how to sort an array with loops only.Yes, we do know how to do it, I once wrote a heapsort in assembly code, as a real work project. But you rarely get a project like that the good ones were all done years ago.
    All the algorithms I suggested you look at use loops. the simplest and slowest is the bubble sort. This one runs by comparing values and swapping their locations, the wikipedia article http://en.wikipedia.org/wiki/Bubble_sort has the algorithm.

  • List of materials with respect to Class type/

    Dear all,
    In which Tcode or table can i find the list of materials with respect to any class type ?
    Table name for Batch Class ?
    or
    How to find KLART ?
    Edited by: Shailesh2510 on Feb 22, 2010 10:55 AM

    hiii
    To get the class type and class , go to table TCLA or TCLAT.
    And one more thing , here standard system , there is transaction code to get class wise materials list.
    If u want u can cevelop custom reports with help of ABAPer.
    If u give the functional details to technical consuiltant , they easily build the report how ever and what ever u want in custom transaction code.
    Any clarification revert,.

  • Sorting a array into classes

    Hello everybody,
    i have a tricky (hopefully just for me! ) problem. I want to sort a 1d array of values into size-classes. First I wrote a code-monster without a loop. Works fine but to increase the number of size classes is really awful. Now I want to make the code more flexible. Just give a 1d array of size-class limits like [0,1,2,4,8..] and the raw data to the vi. As result I want a x-d Array like in the picture below.
    I wrote a code for that but after many hours of work it doesn’t run. Could anyone look to the code sample in the file and give me a hint?
    Thank you in advance!
    Paul
    PS: In the following picture want to show how it should work in the end.
    Solved!
    Go to Solution.
    Attachments:
    Array-sort.vi ‏27 KB

    Hello,
    thank you very much for the given hints and codes. I used in the end a mixture of the code sample from Duri and the hints from RavensFan because it helped me to solve different problems at once. The source from Jeff is really elegant too!
    Thank you! 

  • Help C# Hi, i have studying for 3 weeks and i need some help. How can i sort case 2 and display that with dinamic array?

      //Meny
                Console.WriteLine("\n HÄNGA GUBBE\n");
                Console.WriteLine(" 1) Lägg till ord");
                Console.WriteLine(" 2) Lista alla ord");
                Console.WriteLine(" 3) Spela");
                Console.WriteLine(" 4) Avsluta");
                int valet;
                Console.Write("\n\tVälj 1-4:  ");
                valet = int.Parse(Console.ReadLine());
                switch (valet)
                    case 1:
                        Console.WriteLine("\n lägg ett till ord! ");
                        break;
                    case 2:
                        Console.WriteLine("\n Lista med alla ord :\n");
          char[] array = { 'lev', 'skratta', 'gledje', 'gråt', 'njut'};  
                Array.Sort<char>(array);
                foreach (var c in array)
                    Console.WriteLine(c);
                Console.WriteLine("\n");
                        //List<string> list = new List<string>();
                        //Random r = new Random();
                        break;
                    case 3:
                        string guesses, bokstäver;
                        Console.Write("\n Hur många fel får man ha? ");
                        guesses = (Console.ReadLine());
                        Console.WriteLine(" Utmärkt, då spelar vi!\n");
                        Console.WriteLine(" Felgisningar :" + "0/" + guesses);
                        Console.Write(" Gissade bokstavär: \n" );
                        bokstäver = (Console.ReadLine());
                        Console.WriteLine("Aktuel ord");
                        Console.WriteLine("Gissa bokstav : "+bokstäver+" \n");
                        break;
                    case 4:
                        Console.WriteLine("\n  HEJ DÅ! \n");
                        Console.Beep();
                        break;
                    //avbryter while loopen, avslutar spelet

    You can do it like this;
    var text = Console.ReadLine();
    if(array.Contains(text)) // if exists do what ever you want
    Please mark it correct if you find the answer helpful and please start  a new thread if you have another question. Thanks.

  • Calling an array from another class

    Ok I have this little program that I created to display values stored in an array. Well, I want my array to automatically be populated with the same values that are in another array that resides in a different class. Here is my code for the class that I want the values to be displayed:
    import javax.swing.*;
    import java.awt.*;
    public class GUIRead extends JFrame
         double[] interest = new double[3];
         MemicCSVReader[] interestObjectArray = new MemicCSVReader[3];
         interestObjectArray[0] = new MemicCSVReader();
         interestObjectArray[1] = new MemicCSVReader();
         interestObjectArray[2] = new MemicCSVReader():
         for(int x = 0; x < 3; x++)
         JPanel display = new JPanel();
         JTextField interestText = new JTextField(10);
         JPanel display2 = new JPanel();
         JTextField interestText2 = new JTextField(10);
         JPanel display3 = new JPanel();
         JTextField interestText3 = new JTextField(10);
         public GUIRead()
              super("Test");
              setSize(160,200);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setVisible(true);
              GridLayout config = new GridLayout(3,1);
              FlowLayout config2 = new FlowLayout(FlowLayout.LEFT,10,10);
              Container pane = getContentPane();
              pane.setLayout(config2);
              display.setLayout(config2);
              display.add(interestText);
              interestText.setText(interest[0]);
              interestText.setEditable(false);
              pane.add(display);
              display2.setLayout(config2);
              display2.add(interestText2);
              interestText2.setText(interest[1]);
              interestText2.setEditable(false);
              pane.add(display2);
              display3.setLayout(config2);
              display3.add(interestText3);
              interestText3.setText(interest[2]);
              interestText3.setEditable(false);
              pane.add(display3);
              setContentPane(pane);
         public static void main(String[] args)
              GUIRead run = new GUIRead();
    Here is my code that I want the double[] interest array to pull it's data from:
    public class MemicCSVReader
         double interestArray[];
         MemicCSVReader()
              String[] interestString = {"5.5","5.35","5.75"};
              for(int x = 0; x < 3; x++)
                   interestArray[x] = Double.parseDouble(interestString[x]);
    }

    Ok, thanks for your help. Now I have another problem. I can't get the values to display. Here is my code:
    This is the program that runs the application:
    import javax.swing.*;
    import java.awt.*;
    public class GUIRead extends JFrame
         MemicCSVReader readCSV = new MemicCSVReader();
         double[] interestDouble = readCSV.getInterestArray();
         String[] interest;
         JPanel display = new JPanel();
         JTextField interestText = new JTextField(10);
         JPanel display2 = new JPanel();
         JTextField interestText2 = new JTextField(10);
         JPanel display3 = new JPanel();
         JTextField interestText3 = new JTextField(10);
         public GUIRead()
              super("Test");
              setSize(160,200);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setVisible(true);
              GridLayout config = new GridLayout(3,1);
              FlowLayout config2 = new FlowLayout(FlowLayout.LEFT,10,10);
              Container pane = getContentPane();
              pane.setLayout(config2);
              display.setLayout(config2);
              display.add(interestText);
              interestText.setEditable(false);
              pane.add(display);
              display2.setLayout(config2);
              display2.add(interestText2);
              interestText2.setEditable(false);
              pane.add(display2);
              display3.setLayout(config2);
              display3.add(interestText3);
              interestText3.setEditable(false);
              pane.add(display3);
              setContentPane(pane);
         public void actionPerformed()
              for(int x = 0; x < 3; x++)
                   interest[x] = Double.toString(interestDouble[x]);
              interestText.setText(interest[0]);
              interestText2.setText(interest[1]);
              interestText3.setText(interest[2]);
         public static void main(String[] args)
              GUIRead run = new GUIRead();
    This is the file that it pulls the array from:
    public class MemicCSVReader
         private double[] InterestArray = new double[3];
         MemicCSVReader()
              double[] InterestArray = {5.5,5.35,5.75};
         public double[] getInterestArray()
              return InterestArray;
    }

  • Doubt in customizing request with respect to table entries

    Hi All,
    I have a doubt in customizing request with respect to table entries.
    Suppose I have a customizing request with respect to a table that contains say 10 entries in the development system.
    Now I am transporting this request to the quality system in which the same table contains 20 entries.
    When I am transporting this table from the development system to the quality system, will my 10 entries in the development system get added to the 20 entries in the quality system or will my table get overwritten in the quality system.
    What difference will this be if it is a workbench request ? .
    Regards,
    Sushanth H.S.

    Hello,
    So if we are transporting contents of a table from one system to another, it should always be a customizing request and not a workbench request right.
    If the "Delivery Class" of the table is 'C'(Customizing table, maintenance only by cust., not SAP import) it will ask for a customizing request.
    If it is 'A'(Application table (master and transaction data)), it will ask for Workbench.
    To add to your previous qn, when you transport the entries to subsequent system it will always check the KEY FIELDS and then update. If you see a transport, then the table entries are represented by their key fields.
    If you create new entries in your table and transport, it will add the records. Else it will modify them
    Hope i am clear.
    BR,
    Suhas
    Edited by: Suhas Saha on Jan 23, 2009 11:51 AM

  • How to initialize Object  Array Data Provider (OADP)with data from txt file

    Hi,
    I want to show in a table some columnar data from a txt file. I ran the creator demo application on OADP successfully. http://blogs.sun.com/divas/entry/using_the_object_array_data
    I created a javabean class to read a txt file.However, I am stuck at how I can fill the data into an OADP array:
    I am familiar with C extensively but not much at java. can anyone help??
    thanks..
    dr.am.mohan rao

    Thanks for that. I changed it a little bit, but when i ran this script, got ORA-06532: Subscript outside of limit.
    declare
    O_voucher_comment SYSADM.AP_COMMENT_COLL := sysadm.ap_comment_coll(null);
    begin
    FAS_AP_EXCEPTIONS.GET_VOUCHER_COMMENTS('FCCAN', '20494753', 0, 'KEHE', O_voucher_comment);
    end;
    PROCEDURE get_voucher_comments (
    v_bu_in IN VARCHAR2,
    v_voucher_in IN VARCHAR2,
    v_line_in IN NUMBER,
    v_userid IN VARCHAR2,
    voucher_comment OUT      sysadm.ap_comment_coll
    IS
    i NUMBER := 1;
    v_comments VARCHAR2 (254) := ' ';
    comment_type sysadm.ap_comment_type;
    v_line_num NUMBER := 0;
    CURSOR get_all_comment
    IS
    SELECT voucher_line_num, descr254_mixed FROM ps_fas_ap_comment
    WHERE business_unit = v_bu_in AND voucher_id = v_voucher_in;
    CURSOR get_line_comment
    IS
    SELECT descr254_mixed FROM ps_fas_ap_comment
    WHERE business_unit = v_bu_in AND voucher_id = v_voucher_in
    AND voucher_line_num = v_line_in;
    BEGIN
    --voucher_comment() := SYSADM.ap_comment_type (NULL, NULL, NULL, NULL, NULL, NULL);
    --' ', ' ', 0, ' ', '', ' ' sysadm.ap_comment_coll
    voucher_comment := sysadm.ap_comment_coll(null);
    IF v_line_in = 0
    THEN
    OPEN get_all_comment;
    LOOP
    FETCH get_all_comment
    INTO v_line_num, v_comments;
              if i > 1
              then
                   voucher_comment.EXTEND;
              end if;
    voucher_comment (i) := ap_comment_type (v_bu_in,
    v_voucher_in, v_line_num, v_userid,
    TO_DATE (TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS'), 'DD-MON-YYYY HH24:MI:SS'), v_comments );
    i := i + 1;
    END LOOP;
    ELSE
    OPEN get_line_comment;
    LOOP
    FETCH get_line_comment
    INTO v_comments;
              voucher_comment.extend(6);
    voucher_comment (i) := ap_comment_type (v_bu_in, v_voucher_in, v_line_num, v_userid, TO_DATE (TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS' ), 'DD-MON-YYYY HH24:MI:SS'), v_comments);
    i := i + 1;
    END LOOP;
    END IF;
    END get_voucher_comments;

  • Sort 1D Array

    La fonction "Sort 1D Array" accepte en entrée un Tableau de n'importe quel type.
    N'importe quel type ... hmmm, presque.
    Returns a sorted version of array with the elements arranged in ascending order.
    If array is an array of clusters, the function sorts the elements by comparing the first elements.
    If the first elements match, the function compares the second and subsequent elements.
    Résolu !
    Accéder à la solution.

    oui, j'avais remarqué ... si on place le string en 1er dans le Cluster ... la fonction accepte.
    Dans ce cas, le tri s'effectue sur le string et la fonction ne tient pas compte de la présence de la ref.
    Dans l'absolu, vouloir "trier" des references entre elles n'a pas de sens.
    Il faudrait trier l'équivalent U32 .... cela, à mon sens, est vide de sens.
    par contre la fonction "recherche" accepte une Ref. ... mais rechercher une référence a du sens.
    Les fonction "Tri" et "Recherche" ont toutes les deux cette même phrase dans leur "doc_help" respective.
    "accepte un Tableau de n'importe quel type".
    Pour la fonction "recherche", c'est parfaitement juste ... pour la fonction "Tri", cette phrase est fausse.
    Je voulais pointer la doc qui parfois est lègèrement erronée.
    Petit défaut de ma part, je suis perfectionniste ... mais je me soigne.
    En fait, je suis perfectionniste uniquement pour ce qui a une réelle importance pour moi.
    Pour le reste, je peux laisser tout pourrir en tas et enjamber le chose ... sans le moindre scrupule  

Maybe you are looking for

  • Help Plz Deadline! - Large PNG Wont Open in Illustrator

    Could someone who knows please help as soon as possible I have two versions of a PNG file, one in medium size and the other in XLarge size for print... The medium opens fine but as its for print i need the XLarge to open I have found no way to get it

  • Safari open PDF as a Quicktime file

    When I click on a link for a pdf, I see the only the first page and it's showing that it opened the document with the quicktime plugin. Any ideas? Bill

  • Save Form As An HTML File

    Hi. I recently asked how to save the actual rendered HTML code for a form. However, since posting that I found out that my management really just wants to have a form saved as an HTML (.html) file. And so, I decided to post this question under a new

  • ITunes install in Domain using GPO

    This is a copy from Installing iTunes. I was asked to post this here: I would like to publish iTunes as well as Quicktime using Group policies in our Active Directory. This seems to be close to impossible as far as I can tell. Is this possible, or wi

  • Installing Reader 11

    Unable to completely install Reader 11 after dozens of trial, I followed the link suggested by some forum members. Unfortunately, the link provides a download and installation only of Reader 9.5, which is not the version required by the government of