ordering

Ordering columns in Rails, cakephp style.

CakePHP's built in pagination helpers automatically allow column ordering in the view. If you bake the view you get a link on each column to order it by that data. Is there a way to get this functionality in Rails? The standard will paginate doesn't offer it, anyone know any good ones? ...

MySQL top count({column}) with a limit

I have a table with an ip address column. I would like to find the top five addresses which are listed. Right now I'm planning it out the following: Select all distinct ip addresses Loop through them all saying count(id) where IP='{ip}' and storing the count List the top five counts. Downsides include what if I have 500 ip addresses...

Ordering PHP array by number of identical objects.

Is there anyway to order an array in this way? For example if I had this array: $array = array("foo", "bar", "item", "item", "foo", "foo"); And I wanted to order it so that it was "foo", "foo", "foo", "item", "item", "bar" is there any way to do that? ...

Linked List. Insert integers in order

I have a linked list of integers. When I insert a new Node I need to insert it not at the end, but in oder... i.e. 2, 4, 5, 8, 11, 12, 33, 55, 58, 102, etc. I don't think I am inserting it in the correct position. Do see what Im doing wrong? Node newNode = new Node(someInt); Node current = head; for(int i=0; i<count; i++){ ...

Order awesome nested set array for combo box lookup

I'm using Awesome Nested Sets and Formtastic within Rails and am having trouble listing the nester set records in a structured order within a lookup (combo) box. I'd list to show the lookup box like so: -Parent1 --P1Child1 --P1Child2 -Parent2 --P2Child1 --P2Child2 --P2Child3 etc... Origionally the lookup box was displaying the resul...

Renumbering numerically ordered div ID's when adding one in the middle with Javascript

I'm developing an application with javascript. What I need is to have divs with id's (1,2,3...) and be able to insert a div between, for example, 2 and 3, with jquery, and then have that be the new three, and three becomes four, four becomes five, etc. I've got the div insertion working, I just need to know how to reorder the divs. Any i...

PHP (images folder) image Listing in Alphabetical Order?

Hello, I'm having problems with a PHP script trying to list images alphabetically. I need this urgently and I have not much knowledge of PHP. I was trying to use scandir() but I'm not succeeding. Thanks for your help!! Here is the code: function listerImages($repertoire){ $i = 0; $repertoireCourant = opendir('./'.$repertoire); whi...

Custom ordering of series field for stacked chart in SSRS08 TFS

Hi all--I'm having some issues with a report I'm trying to create for TFS work items that creates a stacked chart based on work item state and the cumulative count. I have Sum(Cumulative_Count) as the data field, System_State as the series field and Date as the category field. The problem I'm having is that for this stacked chart to be ...

How can I order my entries by sum from a separate table?

I am wondering how I can order posts in my PostController#index to display by a column total in a separate table. Here is how I have it set up. class Post < ActiveRecord::Base :has_many :votes end and Class Vote < ActiveRecord::Base :belongs_to :post end I user can either vote up or down a particular post. I know there are li...

Is std::pair<int, std::string> ordering well-defined?

It seems that I can sort an std::vector<std::pair<int, std::string>>, and it will sort based on the int value. Is this a well defined thing to do? Does std::pair have a default ordering based on it's elements? ...

Getting a java collection of objects in Alphabetical order

I have a question that I dont really know where to start. So I thought i'd ask it here. Basically, I have a drop down with names in it. I want these names to be in alphabetical order. Populating the drop down happens as follows; I query a database and pull down an Id and Name, make a object called "UserList", and set the name and id v...

Can Python's set absence of ordering be considered random order?

Hello people. I'd like to know if the absence of element ordering of the Python's built-in set structure is "random enough". For instance, taking the iterator of a set, can it be considered a shuffled view of its elements? (If it matters, I'm running Python 2.6.5 on a Windows host.) ...

Ordering .each results in the view...

I am wondering if it is possible to dictate the order (i.e. :order => 'created_at DESC') within the view. I realize that logic in the view is not ideal but I seem to be having some problems locating where to affect this output. For instance, here is my code: <% @user.questions.each do |question| %> <%= link_to_unless_current h (ques...

How to preserve order of temp table rows when inner joined with another table?

Does an SQL Server "join" preserve any kind of row order consistently (i.e. that of the left table or that of the right table)? Psuedocode: create table #p (personid bigint); foreach (id in personid_list) insert into #p (personid) values (id) select id from users inner join #p on users.personid = #p.id Suppose I have a list of ID...

Complicated football league Dynamic Ordering in MySQL?

I have a table 'games' for a football league as follows: date home_team_id away_team_id home_score away_score - 1 2 6 21 - 3 1 7 19 I can't figure out how to dynamically generate a list of team ID's ordered by Wins (then...

google collections ordering on map values

I would like to order a map(A,Double) based on the values. Function<Map.Entry<A, Double>, Double> getSimFunction = new Function<Map.Entry<A, Double>, Double>() { public Double apply(Map.Entry<A, Double> entry) { return entry.getValue(); } }; final Ordering<Map.Entry<A, Double>> entryOrdering = Orde...

How can I order fields in Django ModelForm?

I have an 'order' Model: class Order(models.Model): date_time=models.DateTimeField() # other stuff And I'm using Django ModelForm class to render a form, but I want to display date and time widgets separately. I've came up with this: class Form(forms.ModelForm): class Meta: model = Order exclude = ('date_time',) date = forms...

Cakephp, good ordering / sorting behaviour?

Hi, Does anyone know any good ordering and sorting behaviours for cakephp? The sort where I can have "Move Up", "Move Down", "Move to top" and "Move to bottom"? That sort of this. Thanks! ...

SQL - Order against two columns at the same time (intersecting)

I have a table with the fields CommonName and FirstName. Only either field has data, never both. Is there a way to order rows in an intersecting manner on SQL Server? Example: CommonName FirstName Bern Wade Ashley Boris Ayana I want records ordered like this: CommonName FirstName Ashley Ayana Bern Bo...

Re-order mysql rows using PHP

| id | url | title | menu_id | ------+--------+--------+---------- | 1 | http://| link 1 | 1 | | 2 | http://| link 2 | 2 | | 3 | http://| link 3 | 3 | | 4 | http://| link 4 | 4 | Hi, I was wondering if its possible using PHP to reorder the above to something like below. I am trying to generate a men...