BucketSort | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

BucketSort

I have problems with the bucket sort, I mean I'm trying to make it with jagged arrays to put in it the buckets and then sorted. I been reading and many examples has been created with a list but... Someone has any idea to make it with arrays...or I have give up and try it with lists .. sorry by my English ! ,🙏

22nd Jan 2021, 5:09 AM
Monica Martinez
Monica Martinez - avatar
1 Answer
+ 3
var jaggedarray = new int[3][]; jaggedarray[0] = new int[5] { 99, 999, 49, 79, 59 }; jaggedarray[1] = new int[3] { 199, 1999, 149 }; jaggedarray[2] = new int[2] { 999, 500 }; Array.Sort(jaggedarray, new Comparison<int[]>( (x,y) => { return x[1] < y[1] ? -1 : (x[1] > y[1] ? 1 : 0); } ));
13th Feb 2021, 5:04 AM
hossein B
hossein B - avatar