question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sorting of uchar array of a million elements with sorted indices?

See original GitHub issue

Hi @DragonSpit What to you suggest the best algorithm for sorting a ‘uchar array’ of a million elements and getting sorted indices? e.g. uchar data[10] = {2,8,6,25,255,23,96,102,235,0}; // actual one has million values

Output:

{4, 8, 7, 6, 3, 5, 1, 2, 0, 9}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
DragonSpitcommented, Mar 22, 2019

I’ve implemented the function you’re after, with an input of unsigned byte array and the output of sorted indexes. The function is SortRadixReturnIndexes(). Look for it at the bottom of RadixSort.cs source file in the HPCsharp folder. I have not tested it yet - will test it this weekend. Just wanted to give you a head start of thinking about porting it from C# to C++, which should be pretty simple, since the function is self contained and doesn’t call any other functions and uses nothing but arrays.

1reaction
DragonSpitcommented, Mar 26, 2019

You’re welcome. Yours is a very nice solution also, as it comes with the same realization that we need to reflect something (i.e. go backwards). Both should perform nearly the same.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there an easy way to sort an array of char*'s ? C++
I've got an array of char* in a file. The company I work for stores data in flat files.. Sometimes the data is...
Read more >
How to sort a big array with many repetitions?
1) Create an empty AVL Tree with count as an additional field. 2) Traverse input array and do following for every element 'arr[i]'...
Read more >
Java.util.Arrays.sort() Method
Arrays.sort(char[] a, int fromIndex, int toIndex) method sorts the specified range of the specified array of chars into ascending numerical order.
Read more >
Sorting Algorithms Explained with Examples in JavaScript, ...
Insertion sort and quick sort are in place sorting algorithms, as elements are moved around a pivot point, and do not use a...
Read more >
Sorting Algorithms in Python
In this tutorial, you'll learn all about five different sorting algorithms in Python ... It took 73 seconds to sort the array with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found