• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sorting ArrayList objects based on an array attribute  RSS feed

 
Tresa Rose
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need to sort an ArrayList of Drawing objects. The Drawing objects should be sorted on the creator and then on the version number.



Please tell me how the objects can be sorted based on the array.

Thanks
Tresa
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please tell me how the objects can be sorted based on the array.

That depends on what criteria about the array determines sort order. Do longer arrays come before shorter ones? Or do you want to sort by version number somehow?

How would you decide if one array comes before or after another?
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm confused about why a Drawing object would have an array of version numbers. Wouldn't each Drawing object have its own version number?

Could you explain how you use the array?
 
Tresa Rose
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you are right Keith.

Each Drawing object has its own version number (May be more than one). I am querying the database and for each Drawing object, am putting its associated versions into an array. (This is the drwgVerNo array).

I think its better to rename the Drawing class as QueryResultDrawing.


Do longer arrays come before shorter ones? Or do you want to sort by version number somehow?


Garrett,
Longer arrays come before shorter ones. If they are of the same size, then they need to be sorted by the version number.

Please indicate how to proceed with the above.

Thanks for the prompt responses.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!