sorting

Sort String "13,5,8,4,2,1,9" in ascending order 1,2,4,5,8,9,13 in Java

How can I sort a string "13,5,8,4,2,1,9" in ascending order, to get 1,2,4,5,8,9,13? ...

WPF ItemsViewSource Sorting

Greetings, I have a problem with sorting ItemsViewSource in WPF. The problem is as follows: My application has a listbox with items, there is a possibility to add new items to this listbox. I have ItemsViewSource which is of type CollectionViewSource and bouned to ObservableCollection as follows: _ItemsViewSource.Source = Children; W...

Python analog of natsort function (sort a list using a "natural order" algorithm)

I would like to know if there is something similar to PHP natsort function in python? l = ['image1.jpg', 'image15.jpg', 'image12.jpg', 'iamge3.jpg'] l.sort() gives: ['image1.jpg', 'image12.jpg', 'image15.jpg', 'iamge3.jpg'] but I would like to get: ['image1.jpg', 'iamge3.jpg', 'image12.jpg', 'image15.jpg'] UPDATE Solution base ...

how to sort a multidemensional array by an inner key

i have this enormous array that i am pulling from an API for BattleField Bad Company 2, and the soldier stats can be pulled as a multi dimensional array with an inner array for each soldier, however the API sormats it sorting the soldiers by name alphabetically, i want to sort them by rank (which is just another key within that soldiers ...

how to sort a queue using (just) another queue and some varibles, in less than O(n^2)?

How can I sort a queue of size N, using just another queue of size N, and a finite number of variables? the naïve implementation - finding the minimum of the queue and pushing it to the empty queue, then finding the new minimal and pushing it, etc. is O(n^2). is there a more efficient algorithm? ...

Java Bucket Sort on Strings

I can't figure out what would be the best way to use Bucket Sort to sort a list of strings that will always be the same length. An algorithm would look like this: For the last character position down to the first: For each word in the list: Place the word into the appropriate bucket by current character For each of the ...

How to enable Automatic Sorting of IEnumerable Data in GridView?

How can I enable automatic sorting of my BLL which returns a list, CustomerList:List in a GridView? Customer is my own strongly typed class and CustomerList is a List of customers. I know one approach is to set the AllowSorting property to true in the GridView and handle the OnSorting event and calling a sorting method defined in my C...

Sort a list of pointers.

Hello all, Once again I find myself failing at some really simple task in C++. Sometimes I wish I could de-learn all I know from OO in java, since my problems usually start by thinking like Java. Anyways, I have a std::list<BaseObject*> that I want to sort. Let's say that BaseObject is: class BaseObject { protected: int id; public...

fast, clean, C, timsort implementation?

Does anyone know of a clean C/C++ implementation of timsort? The Python sources contain a description and code for the original timsort, but it is understandably full of python-specific calls. Thanks! ...

Sort a data grid based on a specified column.

Developed a winform project using VB 2008. I'm using a .xls sheet as source. My appln has 7 columns and unspecified rows. I want to sort all the columns based on a specified column and allot a serial number as per the sorted order. If two items in the specified column are same we should consider another column for the equal items and sor...

How do I sort an array of Person Objects by using compareto()?

Here is my code: > import java.util.Scanner; import java.util.Arrays; /** This class tests the Person class. */ public class PersonDemo { public static void main(String[] args) { int count = 0; Scanner in = new Scanner(System.in); boolean more = false; Person first = null; Person last = null; ...

Remove files created between certain time stamps.

Last night I had a script go a bit crazy and create a bunch of directories between 3:00 and 3:09am. Is there a quick one liner that will hunt these down and remove them for me? ...

How to sort a list alphabetically and have additional lists sorted in the same order

I have 3 lists, each with equal elements: email addresses, salaries and IDs I'd like to sort the email addresses alphabetically and in some way sort the other 2 lists (salaries and IDs). E.g., Emails: [email protected] [email protected] Salaries: 50000 60000 IDs: 2 1 The puzzle: I'd like to sort Emails such that [email protected] is first and [email protected]...

best way to find similar items in python

I have 1M numbers:N[], and 1 single number n, now I want to find in those 1M numbers that are similar to that single number, say an area of [n-10, n+10]. what's the best way in python to do this? Do I have to sort the 1M number and do an iteration? Thanks ...

How to sort 100GB worth of strings.

Given a harddrive with 120GB, 100 of which are filled with the strings of length 256 and 2 GB Ram how do I sort those strings in Java most efficiently? How long will it take? ...

MySQL: I need to get the offset of a item in a query.

Mysql: i need to get the offset of a item in a query. I have a image gallery: this show 6 image per stack, so when i request image 22 it shows images from 18 to 24. It should first get the offset of the image 22, then get the images from 18 to 24. Another example: i request the image number 62(and offset 62), it will select images with...

Time complexity for Search and Insert operation in sorted and unsorted arrays that includes duplicate values.

1-)For sorted array I have used Binary Search. We know that the worst case complexity for SEARCH operation in sorted array is O(lg N), if we use Binary Search, where N are the number of items in an array. What is the worst case complexity for the search operation in the array that includes duplicate values, using binary search?? Will it...

MySQL - Selecting the top occurring entries

Hi, Should be a simple one. Database is mydb. One of the columns is mydata. What SELECT query do I need in order to select the top 3 occurring results from mydata, but sorted alphabetically? For example, if my data is this: mydata ====== kilo (x 1 occurrence) lima (x 9 occurrences) golf (x 5 occurrences) echo (x 9 occurrences) zulu (...

How to sort in-place using the merge sort algorithm?

I know the question is not too specific. All I want is someone to tell me how to convert a normal merge sort into an in-place merge sort (or a merge sort with constant extra space overhead). All I can find (on the net) is pages saying "it is too complex" or "out of scope of this text". The only known ways to merge in-place (with...

PHP Inverting content adding (sorting)

Hello, I have this code which will include "template.php" file from inside each of these folders: "content/templates/id1", "content/templates/id2", "content/templates/id3" etc. etc. $page_file = basename(__FILE__, ".php"); require("content/" . $page_file . "/content.php"); $iterator = new RecursiveIteratorIterator( new ...