This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes arrays merge and sorting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "arrays merge and sorting" Watch "arrays merge and sorting" New topic
Author

arrays merge and sorting

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1371
Array1 has 3, 5,7 and array2 has 1,4,9 how to merger these two arrays as single array with elements are in sorting order.

Can i first sort the arrays individually an then merging or first merging the 2 arrays and then do sorting ?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11145
    
  16

you can do it either way.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37879
    
  22
. . . and it should be obvious which will give better performance.
 
jQuery in Action, 2nd edition
 
subject: arrays merge and sorting
 
Similar Threads
Vector operation implementation why JDK preferred arrays over linkedlist
Sorting elements by associated integers.
sorting of elements in an array
Recursion and MergeSort : How is it working ?
about adding two arrays