sorting

Sort NSArray's by an int contained in the array

I have an array, let's call it "array" and inside of the array I have objects like this: "0 Here is an object" "4 Here's another object" "2 Let's put 2 here too!" "1 What the heck, here's another!" "3 Let's put this one right here" I would like to sort the arrays by that number, so it'll turn into this: "0 Here is an object" "1 W...

Storing Python dictionary entries in the order they are pushed

Fellows: A Python dictionary is stored in no particular order (mappings have no order), e.g., >>> myDict = {'first':'uno','second':'dos','third':'tres'} myDict = {'first':'uno','second':'dos','third':'tres'} >>> myDict myDict {'second': 'dos', 'third': 'tres', 'first': 'uno'} While it is possible to retrieve a sorted list or tuple fr...

Removing duplicates on a variable without sorting.

I have a variable that contains the following space separated entries. variable="apple lemon papaya avocado lemon grapes papaya apple avocado mango banana" How do I remove the duplicates without sorting? #Something like this. new_variable="apple lemon papaya avocado grapes mango banana" I have found somewhere a script that accompli...

Save and get arbitrary sort order in SQL Server

My client wants to sort products by drag & drop. The drag & drop part is easy with javascript. My problem is how do I save and get the sort order? I'm using .net c# and SQL Server 2008. When I move a product and drop it in a new position I get the id of the product that's moved, product in front and product behind. With this data I ...

Best item from list based on 3 variables

Say I have the following for a bunch of items. item position item size item length A smaller position is better, but a larger length and size are better. I want to find the item that has the smallest position, largest length and size. Can I simply calculate a value such as (total - position) * size * length for each item, and then ...

java different sorting methods on one set of data

Hello, Suppose that I am collecting n amount of Strings into an array, or an array list, or some other data structure. I want to come up with a design that will allow the user to specify how the Strings will be sorted: -If the user specifies option A, then the Strings will be put into a Vector, and then sorted and printed. -If the u...

Sorting vector in java

I want to sort a vector contains like [a,b,1,3,5,z] both ascending and descending on Java ME, i.e. without using function like Collections.sort() ...

Sorting grouped nodes by taxonomy term

Ok, here's the problem: I have a list of contacts, which i have created in views, that are grouped by taxonomy terms like so: (term:) Staff: (node:) John Doe [email protected] (node:) Jane Doe [email protected] (term:) Management: Fred Doe [email protected] and so on... As it is now, i have no idea w...

Alternative to JQuery hide show? or Jquery Update?

Hi there.. I have nearly finished a table which has hidden object and sorts.. $(".ICS_BlueTable").tablesorter(); $(".ICS_BlueTable").bind("sortStart",function() { $('.ICS_Artist_Hide',this).toggle(); $('tr',this).removeClass("ICS_Artist_Hide"); }).bind("sortEnd",function() { $("tr:gt(4...

how to sort an array which is mostly sorted

i have an array like this: 1,2,3,5,6,4 it is 99% sorted and has 40K elements. i can put them in an array, list, linked list, ... but i don`t know the fastest way to sort them! ...

database sort vs. programmatic java sort

hi, I want to get data from the database(MySQL) by JPA, I wand it sorted by some column value, So, what is the best practice, to: Retrieve the data from the database as list of objects (JPA), then sort it programmatically using some java APIs. OR Let the database sort it by using a sorting select query. ?? thanx in advance ...

Ruby sort_by help unpredictable object attribute

I have an array with 2 different types of objects. They all have similar properties, like ratings / title etc... An example is: array = array.sort_by { |o| [o.type1.rating] } Sometimes the array has 2 object types type1 and type2 is there any way to sort both of them using the sort_by method? ...

Sorting a tables first column after using jQuery UI's sortable?

I got a table which uses jQuery UI's sortable. The first column contains the order number of each row. How do I automatically sort the numbers (in ascending order) in the first column when I sort the rows? This means that only the numbers in the first column will be sorted. Thanks in advance! ...

Preserve multi-column sort in AdvancedDataGrid with dataProvider as GroupingCollection

I have three attributes in my XML object: last name, first name, and age. My sample XML looks like: <dataXML> <info last="Abc" first="Def" age="20"/> <info last="Abc" first="Hij" age="10"/> <info last="Xyz" first="Klm" age="25"/> <info last="Xyz" first="Opq" age="64"/> <info last="Xyz" first="Rst" age="08"/> </dataXML> I am using...

Comparing chararrays in linked list in the C programming language.

How do you compare and sort chararrays in a linked list, cant you compare like this 'Smith' > 'Andersson' ? struct person { char name[20]; struct person *nextPerson; }; . void createNode(PersonPtr *sPtr, struct person t[]){ PersonPtr newPtr; /* pointer to new node */ PersonPtr previousPtr; /* pointer to previus node in list */ P...

Javascript DOM error - Object type not supported

My problem is with a jQuery Sort Table and a jQuery Tab interface in my application. With Chrome and Firefox, I have no problem. But with IE 6/7 this error pops up: Object doesn't support this property or method. The code: $(function(){ $("#sortable").tablesorter(); $("#dashboardtabs").tabs({ fxSlide: true, fxFade: ...

How to Sort Arrays in Dictionary?

I'm currently writing a program in Python to track statistics on video games. An example of the dictionary I'm using to track the scores : ten = 1 sec = 9 fir = 10 thi5 = 6 sec5 = 8 games = { 'adom': [ten+fir+sec+sec5, "Ancient Domain of Mysteries"], 'nethack': [fir+fir+fir+sec+thi5, "Nethack"] } Right now, I'...

Sort one column of data in a csv file in ascending order in java

import java.io.*; import java.util.*; public class Sort { public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new FileReader("data1.csv")); Map<String, String> map=new TreeMap<String, String>(); String line=""; while((line=reader.readLine())!=null){ map.put(getF...

What is the easiest way to sort maps according to values in Java?

I want my hash to sort in descending order according to the values. How do I do that in Java? ...

Advanced/Non common Efficient Sorting Algorithms

I know there are some like: Bubble sort Insertion sort Shell sort Merge sort Heapsort Quicksort Bucket sort Radix sort Distribution sort Shuffle sort And there are some impractical ones like: Bogosort RandomSort Some of the above use comparisons and others do not. Do you know which other Efficient Algorithms or Techniques ...