• Merge and sort arrays into a third one dimensional array (Visual Basic)
    6 replies, posted
I have to merge two one dimensional arrays into a third one dimensional array. This is a project for one of my classes, and I am not supposed to use array methods. The two arrays are listed below: Dim intX() As Integer = {4, 9, 12, 15, 22, 33, 44, 66, 72, 84, 87, 92, 96, 98, 99} Dim intY() As Integer = {6, 8, 12, 16, 24, 31, 68, 71, 73, 74, 81, 93, 94} I need these merged and sorted into intZ(27) so it looks like this: 4, 6, 8, 9, 12, 12, 15, 16, 22, 24, 31, 33, 44, 66, 68, 71, 73, 74, 81, 93, 94 This will be displayed in a text box. Thanks in advance for any help you can provide, it is greatly appreciated.
What is the code you have so far?
Well if it's for a class, don't you think you should work it out for yourself?
[code] intX.Union(intY).OrderBy(n => n).ToArray(); [/code]
Think in steps. You have to: -merge the arrays -sort the result and that's it. There sure are functions that do that, so what's the difficulty?
If the arrays are sorted before merging then there's something he can do to keep the final array sorted as well. Think.
[QUOTE=QuantumPebbel;26732616]4, 6, 8, 9, 12, 12, 15, 16, 22, 24, 31, 33, 44, 66, 68, 71, 73, 74, 81, 93, 94[/QUOTE] Did you generate that list by hand? Then, chances are, you used merge sort (in your head). Think of how that algorithm worked.
Sorry, you need to Log In to post a reply to this thread.