sorting

How do I data mine text?

Here's the problem. I have a bunch of large text files with paragraphs and paragraphs of written matter. Each para contains references to a few people (names), and documents a few topics (places, objects). How do I data mine this pile to assemble some categorised library? ... in general, 2 things. I don't know what I'm looking for, so...

C++ sorting and keeping track of indexes

Using c++, and hopefully the STL, I want to sort a sequence of samples in ascending order, but I also want to remember the original indexes of the newly samples. For example I have a set, or vector, or matrix of samples A : [5, 2, 1, 4, 3] I want to sort these to be B : [1,2,3,4,5], but I also want to remember the original indexes of th...

Fast in-register sort of bytes?

Given a register of 4 bytes (or 16 for SIMD), there has to be an efficient way to sort the bytes in-register with a few instructions. Thanks in advance. ...

How to design table that can be re-sequenced?

I need to make a design decision about database. The requirment is that one database table has an *AUTO_INCREMENT PRIMARY KEY* field called id. By default, each row is shown to user (in web) sorted ascendenting by id. For example, if there are 4 records in the table. The UI will show rows in sequence of 0, 1, 2, 3. Now, there is require...

MySQL update a sorting index column to move items

If I have the following table & data to allow us to use the sort_index for sorting: CREATE TABLE `foo` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `bar_id` INT(11) DEFAULT NULL, `sort_index` INT(11) DEFAULT NULL, PRIMARY KEY (`id`) ); INSERT INTO `foo` (`bar_id`, `sort_index`) VALUES (1,1),(1,2),(1,3),(1,4), (2,1),(2,2),(2,3),(2...

Why won't my sorting method work?

I have an issue with my C++ code for college. I can't seem to understand why my sRecSort() method isn't working. Any help? This is really confusing me! #include <iostream> #include <algorithm> #include <string> #include <fstream> #include <sstream> using namespace std; void sRecSort(string n[], int s[], string e[], int len){ for (in...

Sorting and extracting of dirnames

There are a lot of directories named like web001 web002 ... web123 ... I want to extract a max-number from this set... Something like num="´find -name /dirname sort ... | tail´" with extracting. I have no ideas... Thank you ...

What is test best sorting algorithm for a Doubly LinkedList

Hi, Can someone recommend me a sorting algorithm for my custom link list + example, basically it is similar to the Generic LinkedList so if you could give examples for the Generic LinkedList it will be great. I am planning to implement the merge sort, please advice on the pros/cons as I am not so familiar with any algorithm, just taken...

How to Sort JSON Products with PHP

how would I sort these two products by say "id:17 value:### " {"id":"16","value":"L-AOC000"},{"id":"17","value":"6.00"},{"id":"18","value":"10.00"},{"id":"19","value":"7.52"},{"id":"20","value":"4.75"},{"id":"21","value":"3.50"} {"id":"16","value":"L-AOC001"},{"id":"17","value":"7.00"},{"id":"18","value":"11.00"},{"id":"19","value":"6....

DataView.Count different DataView.Table.Rows.Count

I am using C# and .NET 3.5 and have a GridView that I am setting the dataSource programatically in the code-behind page. I have data in a DataTable and then depending on a column value (isValid boolean) of each Row, I create a new row using DataRowView.AddNew() method into 1 of 2 DataViews - dvValid or dvInvalid. I am NOT creating a new ...

Various ways of implementing bubble sort?

How should I implement the classic bubble sort algorithm? I'd particularly like to see a C++ implementation, but any language (even pseudocode) would be helpful. P.S. Not a homework. ...

What is the most elegant way of shell sorting (comb / diminishing increment sorting) in C#?

Hi SO, Is there a better way to shell sort using C#? // array of integers to hold values private int[] a = new int[100]; // number of elements in array private int count; // Shell Sort Algorithm public void sortArray() { int i, j, increment, temp; increment = 3; while( increment > 0 ) { for( i=0; i < count; i++ ) {...

C# lists - sorting date problem

Hello, I have a C# list collection that I'm trying to sort. The strings that I'm trying to sort are dates "10/19/2009","10/20/2009"...etc. The sort method on my list will sort the dates but the problem is when a day has one digit, like "10/2/2009". When this happens the order is off. It will go "10/19/2009","10/20/2009","11/10/2009","11...

How to sort an array of associative arrays by value of a given key in PHP

Tough to explain so here's an example: $inventory = array( array("type"=>"fruit", "price"=>3.50), array("type"=>"milk", "price"=>2.90), array("type"=>"pork", "price"=>5.43), ); I would like to sort inventory's element by price so I would like: $inventory = array( array("type"=>"pork", "price"=>5.43), array("type"=>"...

ASP.net c# Gridview sorting with custom template fields

Hi all, I can't seem to figure out how to sort my gridview with both databound AND custom fields. The custom field look like this: <asp:Label ID="lblItems" runat="server" Text='<%# GetItems((int)DataBinder.Eval(Container.DataItem, "ObjectCategoryID"))%>' /> It calls for a function which shows how many item the given category has...

CUSTOM SORT XSL ?

Hi This is my XML Structure like this input :- <MYDATA> <DETAILS> <DESCRIPTION>EASE</DESCRIPTION> </DETAILS> <DETAILS> <DESCRIPTION>COMPLEX</DESCRIPTION> </DETAILS> <DETAILS> <DESCRIPTION>SIMPLE</DESCRIPTION> </DETAILS> </MYDATA> I want to display like this using xsl sort it mea...

how to improve natural sort program for decimals ?

Hello, I have std::strings containing numbers in the leading section that I need to sort. The numbers can be integers or floats. The vector<std::string> sort was not optimal, I found the following natural sort program which was much better. I still have a small issue with numbers smaller than zero that do not sort just right. Does anyo...

Fastest way to obtain the largest X numbers from a very large unsorted list?

Hello everyone, I'm trying to obtain the top say, 100 scores from a list of scores being generated by my program. Unfortuatly the list is huge (on the order of millions to billions) so sorting is a time intensive portion of the program. Whats the best way of doing the sorting to get the top 100 scores? The only two methods i can th...

Sorting Divs in jQuery by Custom Sort Order

Greetings Y'all. It's my first time asking a question but having perused the site for about 8 months I think it's an appropriate one. Basically I'm trying to re-sort the child elements of the tag "input" by comparing their category attribute to the category order in the Javascript variable "category_sort_order". Then I need to remove d...

How to sort an array in this way in php

like the function usort in php but if two members compare as equal, their key should be same. for example: $arrayToSort = array(2,6,1,3,3); after sort return array 1 => 1 2 => 2 3 => 3 3 => 3 4 => 6 ...