Sort by arbitrary value of object inside Map

I have a HashMap full of user objects, let's say. I want to sort the user objects in different ways. So if the user object contains name, age, height, weight, etc., I need to sort on any one of those at runtime.
I've seen some example in the forums for sorting a HashMap by value (involves creating a new structure, which is fine), but I guess I need to write a comparator that digs INTO the objects and compares based on properties INSIDE the object. Is this simple to do? Any elegant solution for this? I'm sure I could brute force hack this, but I wanted to use Colleciton and Comparator if at all possible.

Example without any 3rd party libraries (but please do):import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class Test {
    // don't use this, use something like BeanUtils
    // this just serves as a quick example
    private static Object getProperty(Object bean, String propertyName) {
        Object property = null;
        try {
            BeanInfo beanInfo = Introspector.getBeanInfo (bean.getClass ());
            PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors ();
            for (PropertyDescriptor propertyDescriptor: propertyDescriptors) {
                if (propertyDescriptor.getName ().equals (propertyName)) {
                    property = propertyDescriptor.getReadMethod ().invoke (bean);
                    break;
        } catch (Exception exception) {}
        return property;
    public static class PropertyComparator<T> implements Comparator<T> {
        private String propertyName;
        public PropertyComparator (String propertyName) {
            this.propertyName = propertyName;
        public int compare (T a, T b) {
            Object valueA = getProperty (a, propertyName);
            Object valueB = getProperty (b, propertyName);
            // yet again - quite dirty [and not production ready :)], since null isn't instanceof anything
            if (! (valueA instanceof Comparable) || ! (valueB instanceof Comparable)) {
                throw new IllegalStateException ();
            return ((Comparable) valueA).compareTo (valueB);
    public static void main (String... parameters) {
        List<Person> queen = new ArrayList<Person> ();
        queen.add (new Person ("Freddie", "Mercury"));
        queen.add (new Person ("Brian", "May"));
        queen.add (new Person ("John", "Deacon"));
        queen.add (new Person ("Roger", "Taylor"));
        System.out.println (queen);
        Collections.sort (queen, new PropertyComparator<Person> ("firstName"));
        System.out.println (queen);
        Collections.sort (queen, new PropertyComparator<Person> ("lastName"));
        System.out.println (queen);       
    private static class Person {
        private String firstName;
        private String lastName;
        public Person (String firstName, String lastName) {
            this.firstName = firstName;
            this.lastName = lastName;
        public String getFirstName () {
            return firstName;
        public String getLastName () {
            return lastName;
        @Override
        public String toString () {
            return String.format ("%s %s", firstName, lastName);
}(This sorts a list, not a map. I'm sure you'll be able to adapt it to your situation.)

Similar Messages

  • How to get attribute value from an object inside an object in Xpress

    Does anyone know how to get an attribute value from an object in Xpress in a workflow? I have an object structured as follows:
    <ResourceInfo accountId='mj628' tempId='3483372b787ce7dd:-5d99a0c5:130cb238483:-3600'>
    <ObjectRef type='Resource' name='Google Apps'/>
    </ResourceInfo>
    I need if possible to get the name='Google Apps', which is inside the ObjectRef, so I guess its an attribute value of an object inside an object.

    If the ResourceInfo object is accessible in a variable, i.e. named "myResInfo", you just have to check the Java API and call the relevant method:
    <invoke name='getResourceName'>
      <ref>myResInfo</ref>
    </invoke>

  • How to get the values of the objects inside an object??

    Hi,
    I am trying to write code to display name and memory usage of all session attributes, in a recursive way.
    I suppose reflection is needed here, but I can’t figure out how to get the values of the objects inside an object...
    private void handleIt(String attributeName, Object attributeValue) {
         boolean isPrimitiveOrNull = ((null == attributeValue) ||
              (attributeValue.getClass().isPrimitive()));                                         
         if (isPrimitiveOrNull) {
              sb.append("{" + attributeName + ":" + sizeOf(attributeValue) + "}");
         } else {
              sb.append("{" + attributeName + ":" + sizeOf(attributeValue) + "{");               
              Field[] fields = attributeValue.getClass().getDeclaredFields();
              int lim = fields.length;
              String name;
              Object value = null;
              for (int i = 0; i < lim; i++) {
                   name = fields.getName();
                   //LOOK AT THIS LINE: !!!!!!!!!!!!!!!!!!!!!!!!!!!
                   value = fields[i].get(obj); //I don´t know what 'obj' should be??
                   handleIt(name, value);
              sb.append("}");               
    Any suggestions will be greatly appreciated...

    I realized that massive int objects called MAX_VALUE, MIN_VALUE and SIZE where causing the StackOverflow, so I removed them from the analysis.
    This is the resultant code. But I think it isn’t accurate in calculating the real size of objects being got using reflexion.
    Do you or somebody have any more suggestions?
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.ObjectOutputStream;
    import java.lang.reflect.Field;
    import java.util.Enumeration;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    public class SessionMeasurer extends HttpServlet {
         private static final long serialVersionUID = 1470488362727841992L;
         private StringBuilder sb = new StringBuilder();
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              performTask(request, response);
         public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              performTask(request, response);
         public void performTask(HttpServletRequest request, HttpServletResponse response) {
              HttpSession     session = request.getSession(false);     
              String attributeName = "";
              Object attributeValue = null;
              for (Enumeration<?> attributeNames = session.getAttributeNames(); attributeNames.hasMoreElements();) {
                   attributeName = (String)attributeNames.nextElement();
                   attributeValue = session.getAttribute(attributeName);
                   handleIt(attributeName, attributeValue);               
              System.out.println(sb.toString());
         private void handleIt(String attributeName, Object attributeValue) {           
              if (attributeValue != null) {          
                   boolean isPrimitive = attributeValue.getClass().isPrimitive();
                   if (isPrimitive) {
                        sb.append("{" + attributeName + ":" + sizeOf(attributeValue) + "}");
                   } else {
                        sb.append("{" + attributeName + ":" + sizeOf(attributeValue) + "{");               
                        Field[] fields = attributeValue.getClass().getDeclaredFields();
                        String name;
                        Object value = null;
                        int lim = fields.length;
                        for (int i = 0; i < lim; i++) {
                             name = fields.getName();                                                                                                         
                             if (!name.endsWith("_VALUE") && !name.equals("SIZE") && !name.equals("serialVersionUID")) {
                                  try {
                                       value = fields[i].get(attributeValue);
                                  } catch(Exception e) {
                                       //PENDIENTE: Tratamiento excepción
                                  handleIt(name, value);
                        sb.append("}");               
         private int sizeOf(Object obj) {
              //Valid only for Serializables
              ByteArrayOutputStream baos = new ByteArrayOutputStream();
              ObjectOutputStream oos = null;     
              byte[] bytes = null;               
              try {          
                   oos = new ObjectOutputStream(baos);
                   oos.writeObject(obj);
                   bytes = baos.toByteArray();
              } catch(Exception e) {               
                   //PENDIENTE: Tratamiento excepción
              } finally {
                   if (oos != null) {
                        try {
                             oos.close();
                        } catch(Exception e) {
                             //PENDIENTE: Tratamiento excepción                         
                   if (baos != null) {
                        try {
                             baos.close();
                        } catch(Exception e) {
                             //PENDIENTE: Tratamiento excepción                         
              int size = -1;
              if (bytes != null) {
                   size = bytes.length;
              return size;          

  • Sorting Hashtable by value

    All,
    I have a Hashtable with key (String) and value(float) now I want to sort it by value without disturbing the key value match
    I know, it can be done by sorting the keys... and then calling get() to obtain the value for the key but I want exactly opposite..
    Thanks
    Vishal

    Set set = map.entrySet();
    Map.Entry[] entries = (Map.Entry[]) set.toArray(new Map.Entry[set.size()]);
    Arrays.sort(entries, new Comparator() {
              public int compare(Object o1, Object o2) {
         Object v1 = ((Map.Entry) o1).getValue();
         Object v2 = ((Map.Entry) o2).getValue();
         return ((Comparable) v1).compareTo(v2);
    });And how would one genericise(?) the above code snippet?
    I have the following attempt but I continue to receive one unchecked warning.
    Set<Map.Entry<String, String>> set = map.entrySet();
    Map.Entry[] entries = set.toArray(new Map.Entry[set.size()]);
    Arrays.sort(entries, new Comparatorlt;Map.Entry<String, String>>() {
                public int compare(Map.Entry<String, String> e1, Map.Entry<String, String> e2) {
                String v1 = e1.getValue();
                String v2 = e2.getValue();
                return v1.compareTo(v2);
            });

  • Multiple SQL task objects inside a package object is not generating proper DTSX

    
    I am programmatically adding multiple ExecuteSQLtask objects inside a package. I am specifying all the required properties to the ExecuteSQLtask objects.  However, when I save the package object to dtsx, the package looses the properties of some
    of the ExecuteSQLtask object.
    In the below example, I have created 3 ExecuteSQL task objects using the function AddSqlTask. However, once you run it, one of the objects will loose its properties. What makes it more weird is the fact that sometimes, object 1 looses the properties,
    some times, its object number 2. Its random. I know that these objects are COM objects. Is there something I need to careful of when setting the properties ? Why are the values lost when I save them to DTSX ?
    using System;
    using System.Collections.Generic;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Globalization;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;
    using System.Timers;
    using Microsoft.SqlServer.Dts.Runtime;
    using Microsoft.SqlServer.Dts.Runtime;
    using Microsoft.SqlServer.Dts.Tasks.FileSystemTask;
    using Microsoft.SqlServer.Dts.Tasks.BulkInsertTask;
    using Microsoft.SqlServer.Dts.Runtime;
    using Microsoft.SqlServer.Dts.Pipeline;
    using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
    using Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask;
    using Microsoft.SqlServer.Dts.Tasks.ExecutePackageTask;
    namespace PackageCreator
    class Program
    static void Main(string[] args)
    #region Package 1
    Package package1 = new Package();
    #region ConnectionString
    AddSqlConnection(
    package1,
    ConfigurationManager.AppSettings["ServerHostName"],
    ConfigurationManager.AppSettings["SqlServerDefaultDB"]
    #endregion
    AddSqlTask(package1, "P1 - Task1");
    AddSqlTask(package1, "P1 - Task2");
    AddSqlTask(package1, "P1 - TaskFinal");
    #region Add Dependencies
    package1.PrecedenceConstraints.Add(
    package1.Executables[0] as TaskHost,
    package1.Executables[1] as TaskHost
    package1.PrecedenceConstraints.Add(
    package1.Executables[1] as TaskHost,
    package1.Executables[2] as TaskHost
    #endregion
    #endregion
    #region Package 2
    Package package2 = new Package();
    #region ConnectionString
    AddSqlConnection(
    package2,
    ConfigurationManager.AppSettings["ServerHostName"],
    ConfigurationManager.AppSettings["SqlServerDefaultDB"]
    #endregion
    AddSqlTask(package2, "P2 - TaskFinal");
    #region ExecutePackageTaskClass
    Executable exec1 = package2.Executables.Add("STOCK:ExecutePackageTask");
    TaskHost th = exec1 as TaskHost;
    ExecutePackageTask myTask = th.InnerObject as ExecutePackageTask;
    myTask.PackageID = package1.ID;
    #endregion
    #region Add Dependencies
    package2.PrecedenceConstraints.Add(
    package2.Executables[0] as TaskHost,
    package2.Executables[1] as TaskHost
    #endregion
    #endregion
    //new Ispac(package1, package1.ID).DeployAndRun();
    SavePackage(package1);
    SavePackage(package2);
    var packageList = new List<Package>();
    packageList.Add(package1);
    packageList.Add(package2);
    new IspacPackageCollections(packageList).DeployAndRun();
    Console.Read();
    private static void AddSqlTask(Package package, string component)
    //Thread.Sleep(5000);
    package.Executables.Add("STOCK:SQLTask");
    ExecuteSQLTask executeSQLTask = (package.Executables[package.Executables.Count - 1]
    as TaskHost).InnerObject
    as ExecuteSQLTask;
    executeSQLTask.Connection = package.Connections[0].ID;
    executeSQLTask.SqlStatementSource = "insert into [dbo].[SupersetPackageDependencies] (Component) values ('" +
    component + @"')";
    private static void SavePackage(Package package)
    string packageNetworkLocation = @""
    + ConfigurationManager.AppSettings["packageNetworkLocation"]
    + @"\" + package.ID + ".dtsx";
    new Application().SaveToXml(
    packageNetworkLocation,
    package,
    null
    //new Application().SaveToSqlServer(
    // package,
    // null,
    // "ANUPN8470P",
    // null,
    // null
    #region AddConnectionManager
    private static ConnectionManager AddSqlConnection(Package package, string server, string database)
    return AddConnection(
    package,
    "OLEDB",
    String.Format(
    CultureInfo.InvariantCulture,
    "Provider=SQLOLEDB.1;Data Source={0};Persist Security Info=False;Initial Catalog={1};Integrated Security=SSPI;",
    server,
    database)
    private static ConnectionManager AddConnection(Package package, string type, string connectionString)
    ConnectionManager manager = package.Connections.Add(type);
    manager.ConnectionString = connectionString;
    manager.Name = String.Format(
    CultureInfo.InvariantCulture,
    "{0} Connection",
    type);
    return manager;
    #endregion
    public static void AddExecuteSqlTask(
    Package _package,
    string _componentId
    _package.Executables.Add("STOCK:SQLTask");
    // Get the task host wrapper
    ExecuteSQLTask executeSQLTask = (_package.Executables[_package.Executables.Count - 1]
    as TaskHost).InnerObject
    as ExecuteSQLTask;
    #region Set required properties
    executeSQLTask.Connection = _package.Connections[0].ID;
    executeSQLTask.SqlStatementSource = "insert into [dbo].[SupersetPackageDependencies] (Component) values ('" +
    _componentId + @"')";
    #endregion
    //return executeSQLTask;

    Why you do not tell what properties get lost?
    And why is the same get repeated (you want parallel?):
    package1.Executables[0] as TaskHost,
    package1.Executables[1] as TaskHost
    package1.PrecedenceConstraints.Add(
    package1.Executables[1] as TaskHost,
    package1.Executables[1]
    And why not to add them
    like
    package1.PrecedenceConstraints.Add(
    package1.Executables[0] as TaskHost);,
    package1.PrecedenceConstraints.Add( package1.Executables[1] as TaskHost
    Arthur
    MyBlog
    Twitter

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

  • How to Use Sequence Object Inside User-defined Function In SQL Server

    I'm trying to call sequence object inside SQL Server user-defined function. I used 
    Next Value for dbo.mySequence  to call the next value for my sequence created. But I'm getting an error like below.
    "NEXT VALUE FOR function is not allowed in check constraints, default objects, computed columns, views, user-defined functions, user-defined aggregates, user-defined table types, sub-queries, common table expressions, or derived tables."
    Is there any standard way to call sequence inside a function?
    I would really appreciate your response.
    Thanks!

    The NEXT
    VALUE FOR function cannot be used for User Defined function. It's one of the limitation.
    https://msdn.microsoft.com/en-us/library/ff878370.aspx
    What are you trying to do? Can you give us an example and required output?
    --Prashanth

  • [ORA-22905] How to read a field of an object inside another object?

    Greetings,
    I'm a student and in a current exercise we have to work with the Object Oriented Programming functionality of Oracle.
    In the database we defined an object type, which is then considered inside another object type. The thing is, that I cannot read an attribute of the inner object. I've read tens of websites but none of them have helped so far. I've read the PL/SQL User Guide and Reference document also.
    The inner object is defined as follows:
    create type address_t as object (
            street varchar(50),
            city varchar(50),
            pcode number(5,0)
            );The outer object has an object of type address_t inside it:
    CREATE TYPE professor_t as OBJECT(
              code number(2),
              p_name varchar(50),
              address address_t,
              );Also, there is a table named PROFESSORS that stores objects of type professor_t
    First of all, with a simple testing SQL statement I can see the data inside the object professor, even the object address_t:
    SELECT * FROM PROFESSORS WHERE CODE = 13;returns the following:
    CODE    |         NAME      |       ADDRESS
    13      |         JOHN     |       MYSCHEMA.ADDRESS_T('FIFTH AVENUE','NEW YORK',12345)The thing is, I want to read the field street of the object address (of type address_t) inside professor (of type professor_t).
    I could see everywhere that the way to go is to use point notation, and I've seen examples about the command VALUE, but none of the following SQL statements work:
    SELECT VALUE(ADDRESS.STREET) FROM(
      SELECT CODE,P_NAME,ADDRESS FROM PROFESSORS WHERE CODE = 13);
    SELECT ADDRESS.STREET FROM PROFESSORS WHERE CODE = 13;
    SELECT PROFESSOR.ADDRESS.STREET FROM PROFESSORS WHERE CODE = 13;I'd really appreciate if someone could show me how to access the values of the field of the object inside an object.
    Thanks in advance,
    - David
    Edited by: 858176 on May 11, 2011 6:53 PM Formatting

    Great, this worked so far.
    It is curious that you wrote 'profesores' but that is the actual name for the variable. I translated everything to english in order to post it here.
    So, the statement is:
    select value(t).DIRECCION.CIUDAD from profesores t;And It returned:
    VALUE(T).DIRECCION.CIUDAD                         
    Valencia                                          
    New York
    TijuanaAnd, applying the VALUE command to the statement:
    select codigo,
    nombre,
    value(t).DIRECCION.CALLE,
    value(t).DIRECCION.CIUDAD,
    value(t).DIRECCION.CP
    from profesores T WHERE T.CODIGO = 13;Resulting in:
    CODIGO                 NOMBRE                                             VALUE(T).DIRECCION.CALLE                           VALUE(T).DIRECCION.CIUDAD                          VALUE(T).DIRECCION.CP 
    13                     Pepito Pérez                                       Calle de los Rosales 0                           Valencia                                           46023                  That is EXACTLY what I needed.
    Thanks Thomas, It was really helpful !
    Edited by: 858176 on May 11, 2011 7:46 PM

  • Convert Map String, Object to Map String,String ?

    How can I convert a map say;
    Map<String, Object> map = new Map<Striing, Object>();
    map.put("value", "hello");
    to a Map<String,String>.
    I want to pass the map to another method which is expecting Map<String,String>.
    Thanks

    JoachimSauer wrote:
    shezam wrote:
    Because im actaully calling an external method to populate map which returns <String, Object>.Now we're getting somewhere.
    Oh wait, no, we're not! We're back to my original reply:
    What do you want and/or expect to happen if one of the values isn't actually a String object but something else?Nothing like a bit of confusion :). They are and always will be String objects.
    So this external method, call it external1 for now returns a Map<String, Object>, I then want to pass this map to another external method external2 which takes Map <String,String> as a parameter.

  • Need clarification - Object Relational Mapping

    Folks
    I have searched internet , but I could find a simple answer .
    I am preparing for my Interview. I just want to reply for this question in a very simple answer
    if the employer asked me what is Object Relational Mapping and Explain Cascade and the possible values .
    The above question in the context of " Hibernate " .
    I am not sure if this is the correct forum category I am asking , please guide me .
    Thanks
    Matt

    The best simple answer is to say "I have no idea about those terms but I am eager to learn".
    There is no simple answer that will give the impression you know about such stuff when you
    don't, that will not expose you immediately to great embarrassment if they pose the simplest
    followup question.

  • Quicksort using Comparable can sort out negative value well !!

    man , i have waste another day try to solve this logic problem. It was not easy as what i thought. The Qsort method which i found it on the net and i apply it into my java code .. i do understand his code well , however the result does not sort out well especially negative number or if there is there are small number at the end of the array. Below are some result which i compile .Hope someone can help me , i going crazy soon.
    sample 1:
    Before Soft()
    [93, 50, 34, 24, -48, 27, 45, 11, 60, 51, -95, 16, -12, -71, -37, 2]
    After Soft()
    [-12, -37, -48, -71, -95, 11, 16, 2, 24, 27, 34, 45, 50, 51, 60, 93]
    sample 2:
    Before Soft()
    [-93, 50, -34, -24, 48, -27, -45, 11, 60, 51, -95, 16, -12, -71, -37, 2]
    After Soft()
    [-12, -24, -27, -34, -37, -45, -71, -93, -95, 11, 16, 2, 48, 50, 51, 60]
    sample 3 ==> this one is correct ;-)
    Before Soft()
    [93, 50, 34, 24, 48, 27, 45, 11, 60, 51, 95, 16, 12, 71, 37, 20]
    After Soft()
    [11, 12, 16, 20, 24, 27, 34, 37, 45, 48, 50, 51, 60, 71, 93, 95]
    import java.util.*;
    import java.lang.Comparable;
    public class QuickSort {
    // static Comparable [] array;
    public QuickSort(){}
    public static void main ( String [] args){
              QuickSort qs =new QuickSort ( );
              Object [] test = new Object [16];
              test[0]="93";
              test[1]="50";
              test[2]="34";
              test[3]="24";
              test[4]="-48";
              test[5]="27";
              test[6]="45";
              test[7]="11";
              test[8]="60";
              test[9]="51";
              test[10]="-95";
              test[11]="16";
              test[12]="-12";
              test[13]="-71";
              test[14]="-37";
              test[15]="2";
              for (int i=0;i<test.length;i++)
              System.out.println(test);
              System.out.println();
    /* Copy the value from the Object [ ]test into Comparable [] array. /*
    Comparable [] array = new Comparable [test.length];
    for(int i=0;i<array.length;i++)
         array [i]=(Comparable) test[i];          
         System.out.println(array[i]); //test if the value is the same as the test Object //
    System.out.println("Before Soft()");
    System.out.println(Arrays.asList(array));
    qs.sort(array); //call sort method to sort the array
    System.out.println("After Soft()");
         System.out.println(Arrays.asList(array));
    * Sorts the array of Comparable objects using the QuickSort algorithm.
    * @param comparable an array of java.lang.Comparable objects
    public void sort(Comparable comparable[]) {
    QSort(comparable, 0, comparable.length - 1);
    * @param comparable an array of java.lang.Comparable objects
    * @param lowInt int containing lowest index of array partition
    * @param highInt int containing highest index of array partition
    static void QSort(Comparable comparable[], int lowInt, int highInt) {
    int low = lowInt;
    int high = highInt;
    Comparable middle;
    // The partion to be sorted is split into two separate sections which are
    // sorted individually. This is done by arbitrarily establishing the middle
    // object as the starting point.
    if (highInt > lowInt) {
    middle = comparable[(lowInt + highInt) / 2];
    // Increment low and decrement high until they cross.
    while (low <= high) {
    // Increment low until low >= highInt or the comparison between
    // middle and comparable[low] no longer yields -1 (ie comparable[low]
    // is >= middle).
    while (low < highInt && (comparable[low].compareTo(middle) < 0)) {
    ++low;
    // Decrement high until high <= lowInt or the comparison between
    // middle and comparable[high] no longer yields 1 (ie comparable[high]
    // is <= middle).
    while (high > lowInt && (comparable[high].compareTo(middle) > 0 )) {
    --high;
    /*switch over */
    if (low <= high) {
    Comparable obj;
    obj = comparable[low];
    comparable[low] = comparable[high];
    comparable[high] = obj;
    ++low;
    --high;
    if (lowInt < high) {
    QSort(comparable, lowInt, high);
    if (low < highInt) {
    QSort(comparable, low, highInt);

    the problem is solve after cos i cast a string variable into the object comparable. The problem is solve after i use cast Integer into the object.
    regards
    st

  • For Grant nnnnnn, specify a value for object FUND error -Urgent

    I work in SRM area and my knowledge of Grants management is almost nil. We have a PO in SRM which has account assignment associated with a Workorder and Fund. When we look at the Grant it has all green lights and is confirmed by our FI/CO team everything is correct. But since R/3 is giving this message "For Grant nnnnnn, specify a value for object FUND" , I am sure there is something missing somewhere. Some additional information, the PO is from last fiscal year but it was changed for account assignment this fiscal year. But we checked the Fund itself is valid for some more time to come.
    Any ideas on which transaction codes to see, what to look at etc. will be appreciated.
    Thanks

    Hi Manjula,
    You have been facing this issue becuase the sequence of the fields while mapping them is not perfect, hence the 0date field is capturing some other data rather than picking the exact date value.
    Check the order of fields and match it with the file (if you are loading data from a flat file)
    Also, have a look at the weblog which talks about general mistakes in loading from file.
    /people/sergio.locatelli2/blog/2006/11/02/upload-file-in-bw-common-mistakes-and-hints-to-take-in-mind
    Cheers!
    Amit

  • BO - Explorer  Sorting of 0calmonth values

    Is there any possibility to sort the 0calmonth values grouped by Year ?
    Data has been linked from a sap query based Universe. The Problem is that the Explorer system does not sort the values in the right direction. It should be like 11.2009, 12.2009, 01.2010 .....
    [http://www.abload.de/img/sortingzddw.jpg]

    Sorry... There is no custom sort in Explorer... What I've done once was using the Explore More... button to select the items I want, and the sequence in which items are selected matters, so this is a work around for custom sort.
    But in your case, you've got only 6 months, so there'll be no Explore More... option. I suggest change the format of the year month object. For example, put year in the front, so that Explorer will be able to properly sort it out.

  • How can I change the color of a object inside a symbol?

    Hello!
    I'm working on this study and I need to change the color of an object inside a symbol when I click another object.
    The object is called "bola", wich is inside the symbol "ponto" and the clicking object are the colored pencils (each pencil should change the color of the symbol's object, giving the impression you'd selecting a different pencil to draw).
    I think it's simple to understand what I mean when you see the files.
    I already tried this line on click event of the pencils, but it didn't work:
    sym.getSymbol("ponto").$("bola").css("color","#123456");
    Anyone knows how to make that work?
    I would like to improve the experience of drawing as well. I made it with the "mousedown" event. Is that a better way to get a similar effect?
    My files
    Thanks a lot,
    Clayton F.

    Ok here is another sample:
    http://www.meschrene.puremadnessproductions.net/Samples/HELP/LapisB/Lapis.html
    http://www.meschrene.puremadnessproductions.net/Samples/HELP/LapisB/Lapis.zip
    You need to create a var that changes the css background color..
    Hopefully you can understand what I did...
    The text I left showing so that you could see it change...
    I updated the files and all colors should work now.
    Message was edited by: ♥Schrene

  • Problem in reading an object inside another obj in C thru JNI

    Hi All,
    I am passing a java class object from Jave to C thru JNI.
    This object has many integer fields + one object of another class, which also has some fields.
    I am able to read integer fields from C but not able to read fields inside another object.
    Can anyone plz help me in reading the object inside another object from C.
    I m pasting class here for better understanding :
    public class ImageMergeInformation {
    public ImageInformation outputImageInfo;
    public ImageInformation[] inputImageInfo = new ImageInformation[8];
    public int topMargin;
    public int bottomMargin;
    I wanna read ImageInformation obj.
    Plz help me...
    Thanks in Advance,
    Regards,
    Sneha

    You have to get the field id (getFieldID) of the variable you want, e.g. outputImageInfo, then get the object (getObjectField) in that field. At this point, you can start over (get the class, get the field id, get the object).

Maybe you are looking for

  • Use Adobe Reader to Save Form Data

    I use Acrobat 8 Professional to create several forms and enabled usage rights in Adobe Reader so that my users can save the form data locally using Adobe Reader 7 or higher. My questions are: (1.)Is there a limit to saving the form data? For example,

  • Audio book download from iTunes

    I tried to download an audio book to my 2 week old, IPOD Classic....and it won't download and I get a message "The book was not copied to IPOD because it cannot be played on this IPOD.....I don't understand, are there different audiobooks for differe

  • Need to output time

    Hi! I've got a slight problem with my Labview code, and I was hoping you could help me. I'm outputting counts from three sepearte channels and would like to know the time (how many milliseconds from when the vi started) each value was taken. Right no

  • Safari ver. 8.0.3 won't save usernames & passwords?

    I just upgraded to Yosemite 10.10.2 - Safari ver. 8.0.3. I can't get Safari to remember my user names and passwords. I have to keep entering them overtime I go to the many website I go to many times a day. I nave had this problem in the past with the

  • Safari keeps closing web pages, quitting on new iPad Air?

    Any ideas?