Questions tagged [sorted]

This tag refers to a collection of items that has already been arranged in some specific order.

Use this tag for questions dealing with already sorted collections (i.e. reordering them, adding elements to them while still preserving the order, etc.).

297 questions
6
votes
6 answers

Efficient algorithm to produce the n-way intersection of sorted arrays in C

I need to produce the intersection between some sorted arrays of integers in C. I know how to find the intersection between two sorted arrays, but I need to do this for more than two arrays, efficiently and without prior knowledge of the number of…
Iskar Jarak
  • 4,486
  • 4
  • 34
  • 59
6
votes
1 answer

Interpolation search on strings

For those of you not familiar with interpolation search, it is method to search for a value in a sorted array that is potentially faster than binary search. You look at the first and last element and (assuming that the contents of the array are…
user108088
  • 1,046
  • 2
  • 13
  • 28
6
votes
3 answers

Indexing using Redis sorted sets

I would like to get some feedback and suggestions regarding two approaches I'm considering to implementing searchable indexes using Redis sorted sets. Situation and objective We currently have some key-value tables we're storing in Cassandra, and…
Or Neeman
  • 1,126
  • 8
  • 8
6
votes
3 answers

simpest way to get the longest sequence of sorted elements from a given unsorted integer vector in c++

I have an unsorted array and need to extract the longest sequence of sorted elements. For instance A = 2,4,1,7,4,5,0,8,65,4,2,34 here 0,8,65 is my target sequence I need to keep track of the index where this sequence starts
JackNova
  • 3,771
  • 4
  • 28
  • 47
5
votes
4 answers

Sorting in python, and empty strings

Hi I'm using the sorted() function in Python to order a bi-dimensionnal array (I want to sort columns just like it can be done in a classic spreadsheet). In the example below I use itemgetter(0) to sort the grid based on first column's contents. But…
florian
  • 65
  • 1
  • 4
5
votes
13 answers

deleting duplicates on sorted array

Just in case you missed, the question is about deleting duplicates on a sorted array. Which can be applied very fast algorithms (compared to unsorted arrays) to remove duplicates. You can skip this if you already know how deleting duplicates on…
ajax333221
  • 10,585
  • 14
  • 56
  • 89
5
votes
5 answers

Java: What is the best way to find elements in a sorted List?

I have a List sorted by the cats' birthdays. Is there an efficient Java Collections way of finding all the cats that were born on January 24th, 1983? Or, what is a good approach in general?
Jake
  • 14,329
  • 20
  • 64
  • 85
5
votes
3 answers

Loading an STL set with pre-sorted data, C++

I'm working with C++ in Visual Studio 2010. I have an STL set, which I'm saving to file when my program shuts down. The next time the program starts up, I load the (sorted) data back into a set. I'm trying to optimize the loading process, and I'm…
Jugulum
  • 53
  • 4
5
votes
4 answers

Sort list of strings alphabetically

So i have a question, how can i sort this list: ['Pera','mela','arancia','UVA'] to be like this: ['arancia','mela','Pera','UVA'] In the exercise it said to use the sorted() function with the cmp argument.
Doni
  • 65
  • 1
  • 1
  • 6
5
votes
1 answer

Sorted Insertion into Linked List

AoA, I've been attempting to debug a problem in my circular linked list for 12hrs now. The function takes in an ADT which has a start and cursor field. The initial dummy cell points to itself. Insert elements. Repeat elements are not allowed. …
Bilal Siddiqui
  • 335
  • 2
  • 17
5
votes
5 answers

How to sort an ArrayList with object using stream().sorted()

I am having real trouble with using stream and sorted to sort my ArrayList and hope someone can help out. The code uses Croatian words, but I don't think that will be a problem for someone who understands what I mean. This is the…
Ludi Dado
  • 63
  • 1
  • 1
  • 6
5
votes
5 answers

Native C# support for checking if an IEnumerable is sorted?

Is there any LINQ support for checking if an IEnumerable is sorted? I have an enumerable that I want to verify is sorted in non-descending order, but I can't seem to find native support for it in C#. I've written my own extension method using…
Mikkel R. Lund
  • 1,810
  • 25
  • 37
5
votes
2 answers

How to force refresh the DataGridView's content?

I want to make a sorted datagridview input. The following code snippet doesn't quite cut it; even if i put a grd.Refresh, the datagridview doesn't show its updated values. If i press arrow down key and go up again, the grid is refreshing. Is there…
Hao
  • 7,469
  • 18
  • 59
  • 90
5
votes
3 answers

Algorithm to get the number of sorted combinations?

Say there are "n" numbers from which we select "p" numbers (p less than n) such that the selected "p" numbers are sorted. A selected number can be repeated. How can we calculate the number of combinations we can select? For example if we have a set…
Jeewantha
  • 905
  • 10
  • 27
5
votes
1 answer

Collection modify item

I have read tons of articles on choosing the correct collection for a specific implementation, and I understand that in the end it will come down to benchmarking real data, but while I'm busy doing that: What sorted collection in c# allows the…
Vort3x
  • 1,678
  • 2
  • 18
  • 35
1 2
3
19 20