sorting

Default sort order for a select query in SQL Server 2005 and SQL Server 2012

天涯浪子 提交于 2020-02-03 06:36:13
问题 Is there a difference between default sort order for a select query in SQL Server 2005 and SQL Server 2012? I have a table variable without a primary key. When I execute a select query on the table variable in SQL Server 2005, the records are selected and displayed in alphabetical order as per one of the columns. In SQL Server 2012, the records are displayed in the same order as in the parent table. 回答1: There is no default sort order. Unless you specify it in the ORDER BY clause, there is no

Sorting of array with Moment(date) elements

余生长醉 提交于 2020-02-03 06:30:48
问题 I have an array that is populated with moment(Date provided by the database) elements. I am trying to sort the array so that the first element is the oldest and the last element is the newest, but with no success. for (let item of items) { dates.push(moment(item.created)); } dates.sort(function(a,b){ var da = new Date(a).getTime(); var db = new Date(b).getTime(); return da < db ? -1 : da > db ? 1 : 0 }); } console.log(dates); This always prints the current time times number of elements. 回答1:

Restful PATCH on collection to update sorting parameter in bulk

点点圈 提交于 2020-02-03 04:48:51
问题 We have a big list ("collection") with a number of entities ("items"). This is all managed via a RESTful interface. The items are manually sortable via an order property on the item. When queried, the database lists all items in a collection based on the order. Now we want to expose this mechanism to users where they can update the complete sorting of all items in one call. The database does not allow the same order for the same collection_id (unique collection_id + order ), so you can't (and

Restful PATCH on collection to update sorting parameter in bulk

若如初见. 提交于 2020-02-03 04:48:46
问题 We have a big list ("collection") with a number of entities ("items"). This is all managed via a RESTful interface. The items are manually sortable via an order property on the item. When queried, the database lists all items in a collection based on the order. Now we want to expose this mechanism to users where they can update the complete sorting of all items in one call. The database does not allow the same order for the same collection_id (unique collection_id + order ), so you can't (and

OCaml mergesort and time

白昼怎懂夜的黑 提交于 2020-02-02 18:19:47
问题 I created a function (mergesort) in ocaml but when I use it, the list is inverted. In addition, I want to calculate the time the system takes to do the calculation, how can I do it? let rec merge l x y = match (x,y) with | ([],_) -> y | (_,[]) -> x | (h1::t1, h2::t2) -> if l h1 h2 then h1::(merge l t1 y) else h2::(merge l x t2);; let rec split x y z = match x with | [] -> (y,z) | x::resto -> split resto z (x::y);; let rec mergesort l x = match x with | ([] | _::[]) -> x | _ -> let (pri,seg) =

OCaml mergesort and time

孤人 提交于 2020-02-02 18:19:05
问题 I created a function (mergesort) in ocaml but when I use it, the list is inverted. In addition, I want to calculate the time the system takes to do the calculation, how can I do it? let rec merge l x y = match (x,y) with | ([],_) -> y | (_,[]) -> x | (h1::t1, h2::t2) -> if l h1 h2 then h1::(merge l t1 y) else h2::(merge l x t2);; let rec split x y z = match x with | [] -> (y,z) | x::resto -> split resto z (x::y);; let rec mergesort l x = match x with | ([] | _::[]) -> x | _ -> let (pri,seg) =

Bubble Sort in C#

老子叫甜甜 提交于 2020-02-02 16:00:34
问题 I am studying algorithms and I have two bubble sort functions/methods and both of them provide similar result. Can please someone tell me something more about them, such as performance etc? public void BubbleSort() { int temp; for (int outer = upper; outer >= 1; outer--) { for (int inner = 0; inner <= outer - 1; inner++) { if ((int)arr[inner] > arr[inner + 1]) { temp = arr[inner]; arr[inner] = arr[inner + 1]; arr[inner + 1] = temp; } } } } public void BubbleSor2() { int temp; for (int outer =

Bubble Sort in C#

泄露秘密 提交于 2020-02-02 15:56:12
问题 I am studying algorithms and I have two bubble sort functions/methods and both of them provide similar result. Can please someone tell me something more about them, such as performance etc? public void BubbleSort() { int temp; for (int outer = upper; outer >= 1; outer--) { for (int inner = 0; inner <= outer - 1; inner++) { if ((int)arr[inner] > arr[inner + 1]) { temp = arr[inner]; arr[inner] = arr[inner + 1]; arr[inner + 1] = temp; } } } } public void BubbleSor2() { int temp; for (int outer =

Sort rows of a dataframe in descending order of NaN counts

断了今生、忘了曾经 提交于 2020-02-02 11:40:10
问题 I'm trying to sort the following Pandas DataFrame: RHS age height shoe_size weight 0 weight NaN 0.0 0.0 1.0 1 shoe_size NaN 0.0 1.0 NaN 2 shoe_size 3.0 0.0 0.0 NaN 3 weight 3.0 0.0 0.0 1.0 4 age 3.0 0.0 0.0 1.0 in such a way that the rows with a greater number of NaNs columns are positioned first. More precisely, in the above df, the row with index 1 (2 Nans) should come before ther row with index 0 (1 NaN). What I do now is: df.sort_values(by=['age', 'height', 'shoe_size', 'weight'], na

jQuery function doesn't work on Safari

萝らか妹 提交于 2020-02-02 05:59:05
问题 I've one function for sort div by price ASC and DESC. But it doesn't work on Safari . It's ok on Firefox/Chrome. What's the reason? The code (and a fiddle version): function sortByPrice(a,b){ return $(a).find('.cicerone_price').text() > $(b).find('.cicerone_price').text(); } function sortByPriceDesc(a,b){ return $(a).find('.cicerone_price').text() < $(b).find('.cicerone_price').text(); } function reorderEl(el){ var container = $('#tabs'); container.html(''); el.each(function(){ $(this)