Program to arrange 4 strings in ascending order .

can any one gimme the code to arrage 4 strings in ascending order.

create an internal table with a field of  character type of sufficient length..
Now append the fields one after one.
Use sort Table option to get the Required result.
Code.
Report XYZ.
data : begin of t_table occurs 0 ,
         field(255) type c,
       end of t_table.
field = 'abc'.
append field.
field = 'adcg'.
append field.
field = 'afeter'.
append field.
field = 'afar'.
append field.
sort t_table .
Thanks and regards
sharma Nittala
Message was edited by:
        nsk sharma

Similar Messages

  • Arranging 3 integers in ascending order

    i need the code for arranging 3 numbers in ascending order. the numbers will be typed in a input dialog box. someone please help! it's homework for tomorrow dec 16 2005.

    naw, its cool. do you know any web pages where i
    might could find the code?
    e359. Sorting an Array
    It's an extremely important skill to learn how to search the web. Not only will it increase your research and development talents, it will also save you from asking questions that have already been answered numerous times before. By doing a little research before you ask a question, you'll show that you're willing to work and learn without needing to have your hand held the entire time; a quality that is seemingly rare but much appreciated by the volunteers who are willing to help you.
    If you've done the research, found nothing useful, and decide to post your question, it's a great idea to tell us that you've already searched (and what methodologies you used to do your research). That way, we don't refer you back to something you've already seen.

  • I want  to know making a program in  ascending order....

    hi to all...happy holidays
    i have a code of mine but it doesn't work, pls help me...
    class Sorting{     
              void sort(int[]a){
              int i,j;
              int temp;
              for (i=0;i<a.length-1;i++)
                   for (j=i+1;j<a.length;j++)
                        if (a[j]<a)
                             temp=a[j];
                             a[j]=a[i];
                             a[i]=temp;
    that code is for 500 numbers i try to be in ascending order but i doesnt work...
    i want it also that when I type the number it says that these are the numbers i type....Can someone help with a sample code even just up to 11 numbers it accept and displays the number i type first before the output in ascending order....
    Thanks a lot for consideration and help....

    How about:public class Hello {
         public static void main(String[] args) {
              Hello hi = new Hello();
              int[] b = {5,3,7,2,1};
              hi.sort(b);
              for (int k=0; k < b.length; k++)
                   System.out.println(b[k]);
         void sort(int[] a){
              int temp;          
              for (int i=0; i < a.length-1; i++) {
                   for (int j=i+1; j < a.length; j++) {
                        if (a[j] < a) {
                             temp=a[j];
                             a[j]=a[i];
                             a[i]=temp;

  • Creating java program that orders 3 numbers in ascending order using if els

    Does anyone know what code to use for creating a java program that uses the if else operators to order 3 variables in ascending order?

    nar0122 wrote:
    correct on the homework assumption...you have a good nose...the thing is...i know i need to make an if statement saying if a is less than b, and a is less than c...print a first...but how do i get it to "print a" first? if a is less than c and b...and so on for b and c? sorry if that was confusing...
    int a = ..., b = ..., c = ...;
    if(a > b AND a > c) {
      print a
      if(b > c) {
        print b, print c
      } else {
        print c, print b
    etc.

  • Arrange Array in ascending order by date

    Kindly help me sort out the order by problem.
    I have a date array which goes like;
    12/3/2012
    11/3/2012
    12/5/2012
    12/8/2012
    12/6/2012
    12/12/2012
    12/10/2012
    12/17/2012
    I need to arrange it in ascending order, like
    11/3/2012
    12/3/2012
    12/5/2012
    12/6/2012
    12/8/2012
    12/10/2012
    12/12/2012
    12/17/2012
    Please help.
    Thank you in advance.
    Regards
    Grugh Mike
    Success is Everything !!

    Grugh_Mike wrote:
    is'nt there any easier method to sort a time array ?
    It's a lot easier than trying to manipulate the strring into yyyy/dd/mm format and sorting alphabetically.
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

  • Output to appear in ascending order

    Could someone please help me to get the contents of my output file in ascending order.
    I am reading a file mnf.xml kept inside my jar, the contents of it are
    <assets>
    </assets>I am writing the contents of the file mnf.xml to an output file, and am also adding the pdf filenames found in the directory.
    The contents of the output file after running the program are
    <assets>
    <pdf_files name="assets/123_001_ch_03.pdf"/>
    <pdf_files name="assets/123_001_ch_02.pdf"/>
    <pdf_files name="assets/123_001_ch_01.pdf"/>
    </assets>
    But I need my output to be in the following order
    <assets>
    <pdf_files name="assets/123_001_ch_01.pdf"/>
    <pdf_files name="assets/123_001_ch_02.pdf"/>
    <pdf_files name="assets/123_001_ch_03.pdf"/>
    </assets>
    My code is
    void fileMNF(File RootDir, String jTextField1Text)
         String filename=jTextField1Text.substring(0,jTextField1Text.lastIndexOf("."))+"_mnf.xml";
         String Assetsdir=RootDir+"\\"+"assets";
         File files=new File(Assetsdir);     
         String[] lists=files.list();
         try
              int val;
              char ch;
              InputStream is=getClass().getResourceAsStream("/Inputs/mnf.xml");
              File dstfile=File.createTempFile("mnf", ".xml");
              dstfile.deleteOnExit();
              FileOutputStream fos = new FileOutputStream(dstfile);
              int b;
              while((b = is.read()) != -1)
                   fos.write(b);
              fos.close();
              File inputfile=new File(dstfile.getAbsolutePath());
              File outputfile=new File(filename);
              BufferedReader in = new BufferedReader(new FileReader(inputfile));
              BufferedWriter out = new BufferedWriter(new FileWriter(outputfile));
              String line;
              while ((line=in.readLine()) != null)
                   if(line.startsWith("<assets>"))
                        for(int i=0;i<lists.length;i++)
                             if(lists.endsWith(".pdf"))
                                  line = PDFLineInsert(line,lists[i]);
                   out.write(line);
                   out.newLine();
                   out.flush();
              in.close();
              out.close();
         catch(Exception e)
              System.out.println(e.getMessage());
    private String PDFLineInsert(String line, String PDF)
         String res = "";
         res = line.replace("<assets>", "<assets>\n\r<pdf_files name=\"assets/"+PDF+"\"/>");
         return res;

    Your PDFLineInsert method is inserting your lines at the beginning of the file.
    You should change your logic to write the new lines as you get them. something like this:
              while ((line=in.readLine()) != null)
                   if(line.startsWith("<assets>"))
                       out.write(line);
                       out.newLine();
                        for(int i=0;i<lists.length;i++)
                             if(lists.endsWith(".pdf"))
                                  out.write("<pdf_files name=\"assets/"+lists[i]+"\"/>");
                                  out.newLine();
                   out.write(line);
                   out.newLine();
                   out.flush();
              in.close();
              out.close();
    ~Tim
    EDIT: remove the extra '>' in the write statement inside the for loop. it is caused by a bug in the forum software
    Message was edited by:
    SomeoneElse

  • How to arrange the information in alphabetical order in a listbox?

    Can you guys help me out?
    How to arrange the information in alphabetical order in a listbox?
    *The information is taken from a text file using FileReader
    Thanks

    private void jbInit() throws Exception {
    // Get information for the text file
    File f1 = new File("Albums.txt");
    try {
    FileReader fr = new FileReader(f1);
    BufferedReader br = new BufferedReader(fr);
    //Use a loop to read
    for (String str = br.readLine();
    str != null;
    str = br.readLine())
    jListModel.addElement(str);
    //Closing the file
    fr.close();
    catch (Exception ex) {
    JOptionPane.showMessageDialog(this, "Error Retriving File", "error",
    JOptionPane.ERROR_MESSAGE);
    Can you explain to me how to use the Collection class? Above codes is getting the data from my text file and put it into my ListBox(jModelList)... So after inputting the text into it.. how do i arrange it using the Collection?
    Thanks

  • How to sort  the arry value in ascending order

    I have a string array where i need to sort the below values in ascending order in the same format...can anyone give me clue on this?
    9.3
    3.1
    9.1
    19.1
    19
    9.4
    9.1.1
    the sorted order should be
    3.1
    9.1
    9.1.1
    9.3
    9.4
    19
    19.1

    You may have easier luck writing your own comparator for this. These are headings in a table of contents, right?
    Write a comparator that tokenizes a string on the '.' character, or use a StringBuffer to remove them, and then order the elements according to the combined numbers. Since alphanumeric would order this list as you want it anyway you could just order that way once the '.' are removed.
    In other words your comparator would do this in the "compare" method:
    public class MyComparator implements Comparator, java.io.Serializable {
    private static Comparator stringComparator = java.text.Collator.getInstance();
    ...constructor(s), your own private "instance" variable of type MyComparator, a getInstance() method of your own, yadda yadda...
    public int compare(Object item1, Object item2) {
    try {
    value1 = removePeriods((String)item1);
    value2 = removePeriods((String)item2);
    if (value1 == null) {
    return (value2 == null) ? 0 : (-1);
    return compare(value1, value2);
    } catch (ClassCastException cce) {
    System.err.println("Wrong Object Type, JackAss!");
    protected int compare(String str1, String str2) {
    return MyComparator.stringComparator.compare(str1, str2);
    private String removePeriods(String value) {
    StringBuffer sb = new StringBuffer(value);
    int decimalIndex = value.indexOf('.');
    while (decimalIndex != -1) {
    sb.delete(decimalIndex, (decimalIndex + 1));
    }

  • Variable selection screen- text in ascending order

    Hi All,
    Is there a way to display the medium/long text description in ascending order in selection screen?  rather than displaying the key in ascending order.  is it possible?
    thanks

    Hi Abby,
    you can arrange the variables only in the querydesigner. In the settings you can choose the order of the variables.
    I hope this will help.
    Kind regards,
    André

  • Doesn't Sort data in Ascending order in Hash Table?

    Hello
    I am using JSP, Servlets. After quering in servlets, putting data in HashTable then set attribute in servlets, get attribute in JSP & retrieving data from HashTable in JSP & putting in select html element, data is not coming in ascending order in select drop down box. I need A,B,C,D but it is coming b,d,c,a. When I run query in DB, it shows in sequence but after putting in HashTable, it is not coming in sequence.
    How to make it ascending?
    Looking forward for an early reply.
    Thanks.

    Hi
    Something to do with TreeMap(TreeSet). I tried with TreeSet but it didn't work. Here is the code :
    In servlet :
    Connection lConnection = getConnection(pRequest);
    String lSQL = "";
    Statement lStatement;
    ResultSet lResultSet;
    Hashtable lLtypeHashtable = new Hashtable();
    lStatement = lConnection.createStatement();
    lSQL = "SELECT RCID,RCMEANING FROM REFERENCECODES WHERE RCDOMAIN = 'LOCATIONTYPE' AND RCROWSTATE > 0 order by RCMEANING";
    lResultSet = lStatement.executeQuery(lSQL);
    while(lResultSet.next())
    String lRcid = lResultSet.getString(1);
    String lRcmeaning = lResultSet.getString(2);
    lLtypeHashtable.put(lRcid.trim(),lRcmeaning.trim());
    if(lResultSet != null) lResultSet.close();
    if(lStatement != null) lStatement.close();
    pRequest.setAttribute("LtypeHashtable",lLtypeHashtable);
    //Below Query is executed when one data from select element is selected
    String lLType = DisplayUtilities.getString(pRequest.getParameter("LType"),true);
    //LType is name of select element in JSP.
    if (lLType != null)
    lSQL = lSQL + " AND " + lUpperCaseFunction + "(LOCATIONTYPE)" +
    " = " + DBUtilities.formatString(lLType.toUpperCase());
    pRequest.setAttribute("rLType",lLType+"");
    In JSp :
    <%
    Hashtable lLtypeHashtable = (Hashtable)request.getAttribute("LtypeHashtable");
    %>
    <TR>
    <TD width="15%"> <div align="left">
    <select name="LType" size="1" >
    <option Value="">< Select ></option>
    <%
    if(lLtypeHashtable != null)
    Enumeration enum = lLtypeHashtable.keys();
    while(enum.hasMoreElements())
    String key = (String)enum.nextElement();
    String value = (String)lLtypeHashtable.get(key);
    String flagBack = "";
    if(key.equals((String)request.getAttribute("rLType")))
    flagBack = "selected";
    %>
    <option Value="<%=key%>" <%=flagBack%>><%=value%></option>
    <%
    %>
    </select></div>
    </TD>
    </TR>
    How should I implement TreeSet?
    Looking forward for an early reply.
    Thanks.

  • [C] Trying to sort string into reverse order ... Blank. [SOLVED]

    Here are the pre-processors:
    #include <stdio.h>
    #include <string.h>
    Here are the global variables:
    char output[999];
    Here's the function to sort string to reverse order (I THINK THE PROBLEM IS HERE):
    char output[999];
    char *sort_reverse(const char *str)
    int i, j = 0;
    for (i = strlen(str); i > 0; i--)
    output[j] = str[i];
    j++;
    return output;
    And, function int main(void):
    int main(void)
    printf("Reverse of \"Hello\": %s\n", sort_reverse("Hello"));
    return 0;
    The output is:
    Reverse of "Hello":
    Why is that? how can i fix that?
    Last edited by milo64 (2013-03-28 01:45:46)

    Instead of the global char output[999] wich is really big, you could allocate a perfectly sized array with calloc - like this in the sort_reverse function:
    char *output = calloc(strlen(input_string), sizeof(char));
    and in main program:
    char *reversed_string = sort_reverse("Whatever");
    printf("%s\n", reversed_string);
    //Remember to free reversed_string with
    free(reversed_string);
    //Since its allocated in the heap with calloc()
    Try check man-page for calloc, it will zero out the bytes aswell, then you wont have to worry about setting the last element to '\0'.
    NOTE: you have to iterate with "strlen(input_string) - 1" otherwise you will overwrite the needed '\0'
    EDIT:  As strlen excludes the '\0' in original string, then you have to make space for that by adding one to strlen return value so:
    char *output = calloc(strlen(input_string) + 1, sizeof(char));
    Last edited by Boogie (2013-04-05 09:46:12)

  • Ascending Order in Data Level

    Hi Friends,
    I have a table xxx and it has two columns col1 and col2 and below is the data for these columns.
    Col1 Col2
    111 5,6,9,2,1
    211 10,12,8,9
    311 6,7,8,1,2,3,4
    Below is the required output;
    Col1 Col2
    111 1,2,5,6,9
    211 8,9,10,12
    311 1,2,3,4,6,7,8
    I want the column level data in the ascending order. Please help me on this.
    Regards,
    Williams
    Edited by: Williams on Sep 24, 2012 7:11 PM

    Hi, Sankar,
    Here's one way:
    (1) Split each string into multiple rows, one row for each item in the delimited list. (This is how the data should be stored in the frist place.) See {message:id=10095021}
    (2) Use the analytic ROW_NUMEBR (or DENSE_RANK, depending on your requirements) to number the rows 1, 2, 3, ..., using "PARTITION BY col1" to get a separate set of numbers for each value of col1.
    (3) Use String Aggregation to combine the rows into one row per col1. See
    http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
    If you get stuck, post your best attempt, along with a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    Simplify the problem as much as possible. Remove all tables and columns that play no role in this problem.
    Always say which version of Oracle you're using (for example, 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • Sorting an array of integers into ascending order

    Today I decided to blow the cobwebs off my old laptop and see what I could remember from my Java days.
    As a task for myself to see what I could remember, I decided to try and write a program that does the following:
    - Declares an array of 4 integers
    - Sorts the array into ascending order, from lowest to highest.
    - Prints on screen the sorted array.
    After an hour or so I finally cracked it, and ended up with a working program. Here she is:
    public class Sorting_arrays_1
        public static void main()
           int [] array = {4,3,7,1};
           //A variable used to help with swopping values
           int temporary;
              //finds the smallest number out of elements 0, 1, 2, and 3 of the array, then moves it to position 0
              for (int count = 0; count<array.length;count++)
                int smallestNumber = array[0];
                if (array[count] < smallestNumber)
                    smallestNumber = array[count];
                    temporary = array[0];
                    array[0]=array[count];
                    array[count]=temporary;
             //finds the smallest number out of elements 1, 2, and 3 of the array, then moves it to position 1
             for (int count = 1; count<array.length;count++)
                int smallestNumber = array[1];
                if (array[count] < smallestNumber)
                    smallestNumber = array[count];
                    temporary = array[1];
                    array[1]=array[count];
                    array[count]=temporary;        
              //finds the smallest number out of elements 2 and 3 of the array, then moves it to position 2
              for (int count = 2; count<array.length;count++)
                int smallestNumber=array[2];
                if (array[count] < smallestNumber)
                    smallestNumber = array[count];
                    temporary = array[2];
                    array[2]=array[count];
                    array[count]=temporary;     
             //prints the array in ascending order
             for (int count=0; count<array.length;count++)
                 System.out.print(array[count] + " ");
    }Could this code be simplified though? Maybe with a for loop?
    I mean, it does the job, but it looks so clumbsy and inefficient... Imagine how much code I would need if I wanted to sort 1000 numbers..

    Use bubble sort if u want a quick fix
    public static void bubbleSort(int [] a)
    for(int i=0; i<a.length-1; i++)
         for(int j=0; j<a.length-1-i; j++)
              if(a[j]>a[j+1])
                   int temp = a[j];
                   a[j]=a[j+1];
                   a[j+1]=temp;
    Or use Merge sort if u want better run time... ie.(N log N)

  • How To: Sort Numbers in Ascending Order in a Generated List

    Greetings! How do I set up a Generated List of Paragraphs so that it sorts in true ascending order? What I want is:
    1.1
    1.2
    1.3
    1.4
    1.5
    1.6
    1.7
    1.8
    1.9
    1.10
    I have tried every trick I can think of with the sort order listed on the reference page. But all I can get is something that sorts by individual number (ignoring the numeric value) like:
    1.1
    1.10
    1.11
    1.2
    1.20
    1.21
    1.3
    Any help is much appreciated!

    Hello there, Michael! Thanks so much for looking at my post! Alas, the LOP will not work. I should have explained more, but it was so complicated I thought folks would give up reading.
    Here's the best I can render it without getting permission to share a good example document. I do not blame anyone if it's too cumbersome or convoluted to wade through...
    This is a requirements document which has sort of a "legal" tinge to it--as the document evolves we must maintain traceability for individual requirements. This means, for example:
    Version 1 - I have requirements 1 and 2.
    Version 2 - I need to add a new requirement, which should appear before requirement 1 in the document. Even though it comes before requirement 1 in the document, numerically it will be requirement 3 and requirement 1 will remain requirement 1.
    Version 3 - I need to remove requirement 2. Even though I now have only 2 requirements, their numbers will not change (they remain requirements 1 and 3, appearing in reverse order).
    Version 4 - I need to move requirement 3 to be after requirement 1. Again, the requirements keep their original number, even though their position has changed and there is no longer a "requirement 2" number in use.
    Originally, I told the team (I'm doing this for a different dept), that they would have to hand-number requirements, which they did for a while. But that was getting very cumbersome, and the scenarios above are limited to one or two occurrences per document. So I created an auto-number sequence for them to use in the initial version and added a little smoke-and-mirrors work process to take care of changes in later versions. The last bit of chicanery I cannot get to work is the index...
    Even if there are no changes to the requirements after the initial version, the index still does not sort in ascending numeric order. It was working with the hand-numbered requirements because they were using leading zeros. But without being able to include leading zeros in the auto-numbering formats (I tried the "use a zero as a tab leader" solution and like to have thrown my new monitor out of the window), I cannot find a solution.
    Or rather, I think the solution is "you have to hand-number requirements".
    For anyone who has made it this far, I truly appreciate your time and patience!
    SFT

  • I would like to do a program that have one string control and one string indicator, any character that I type in the string control in the same time it will be appear in another string (indicator). How can help me?

    I would like to do a program that have one string control and one string indicator, any character that I type in the string control in the same time it will be appear in another string (indicator). How can help me?

    Why not use an event
    Add a While Loop, inside the loop add the Event Sructure.
    Now in the event structure selecd the String Controls.value change event to
    react
    and the new value inside the event that you get,( connect to the String
    indicator box.
    On Sun, 10 Aug 2003 15:58:47 -0500 (CDT), WiltonFilho wrote:
    > I would like to do a program that have one string control and one
    > string indicator, any character that I type in the string control in
    > the same time it will be appear in another string (indicator). How can
    > help me?
    >
    > I would like to do a program that have one string control and one
    > string indicator, any character that I type in the string control in
    > the same time it will be appear in another string (indicator). How can
    > help me?
    >
    Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

Maybe you are looking for

  • How do I know if the pop-up window is from Adobe or not?

    I sometimes get pop-ups in my browser that tell me I have to update my software. I just got one concerning Flash Player. The link it redirected me to is this one: https://get3.adobe.com/flashplayer/download/?installer=FP_16_Mac_for_Safari_and_Firefox

  • Pictures disappear in Show Photos Settings

    Student can successfully set Ken Burns, adjust time, but when he goes back to edit Ken Burns, the screen is black. We can play the movie, and the pictures play successfully, but obviously, can't edit. Threw away the pictures and started again - same

  • Is possible to work with more than two decimals

    Hi, my CRM OD environment shows only two decimals, but the customer needs four decimals. Is possible these change? How can I do it? Regards.

  • Publish to the web in dreamweaver cs2

    I am very new to building web pages and I thought I would learn in dreamweaver. I am baffled from reading some of this techy stuff in the books that I bought. I need someone who speaks regular english to explain how I publish what I have designed, to

  • Problems when using id = "selection"

    Hi, actually this is not a question but a hint if you get the same problem. If you use htmlb with id = "selection", you will get a JavaScript error after leaving a Input Field. The problem seems to be in the Javascript sapUrMapi_ie6.js, in function u