# Sorting Tasks/Switching Task position

**URL:** <https://forum.sambapos.com/t/sorting-tasks-switching-task-position/22961>\
**Category:** V5 Question\
**Created:** [September 18, 2020, 10:33pm UTC](https://forum.sambapos.com/t/sorting-tasks-switching-task-position/22961 "2020-09-18T22:33:41Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![BCEats](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/b/4491bb/32.png) [@BCEats](https://forum.sambapos.com/u/BCEats)\
**Post date:** [September 18, 2020, 10:33pm UTC](https://forum.sambapos.com/t/sorting-tasks-switching-task-position/22961/1 "2020-09-18T22:33:41Z")

</div>

Hi!  
I’m just wondering, how are tasks sorted?  
Is there any way to change the sort order of the tasks? (Not just by ascending or descending.)

For example:

Task 1 | Task 2 | Task 3 | Task 4

switch Task 3 to second location, becomes:

Task1 | Task 3 | Task 2 | Task 4

Is it sorted by the ID?(not the Identifier)

 ![image](https://forum.sambapos.com/uploads/default/original/3X/0/e/0ef1db0a0f851d7e9d24201d1ecf9e63faf4bc74.png)  
In which case, is there anyway to change the ID?

Thank you!

---

<div class="post-metadata">

**Author:** ![BCEats](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/b/4491bb/32.png) [@BCEats](https://forum.sambapos.com/u/BCEats)\
**Post date:** [September 18, 2020, 10:52pm UTC](https://forum.sambapos.com/t/sorting-tasks-switching-task-position/22961/2 "2020-09-18T22:52:13Z")

</div>

Just was experimenting, and the sort order is changed by the action: Update Task, and editing the End Date.

![image](https://forum.sambapos.com/uploads/default/original/3X/c/7/c7b4417c6c23a7cf533b09ff92906af7eeed658c.png)

now I just need to figure out how to get the name/ID of the task automatically…

---

<div class="post-metadata">

**Author:** ![BCEats](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/b/4491bb/32.png) [@BCEats](https://forum.sambapos.com/u/BCEats)\
**Post date:** [September 19, 2020, 2:38am UTC](https://forum.sambapos.com/t/sorting-tasks-switching-task-position/22961/3 "2020-09-19T02:38:13Z")

</div>

So I am getting the ID/End Date of tasks with SQL:  
 ![image](https://forum.sambapos.com/uploads/default/original/3X/1/4/143e85a548bf578029cf1b5528c4cd04e39ae1ef.png)  
Which returns the below  
 ![image](https://forum.sambapos.com/uploads/default/original/3X/c/8/c883c0f441f8b7c0e94ac8b4f3a102aae69a4666.png)

So using a script(var number is 1)

 ![image](https://forum.sambapos.com/uploads/default/original/3X/5/a/5a71ec2691867ec9e47731f22192a7a9e0911dba.png)

This is what is returned.  
 ![image](https://forum.sambapos.com/uploads/default/original/3X/6/0/60427b696104184675cd5e04bade3ac4f28c3a05.png)

Was there anyway to get milliseconds passed into Samba from SQL?

Thank you!

---

<div class="post-metadata">

**Author:** ![Bob\_be](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@Bob\_be](https://forum.sambapos.com/u/Bob_be)\
**Post date:** [September 19, 2020, 2:58am UTC](https://forum.sambapos.com/t/sorting-tasks-switching-task-position/22961/4 "2020-09-19T02:58:27Z")

</div>

What/where are you wanting to sort tasks?

---

<div class="post-metadata">

**Author:** ![BCEats](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/b/4491bb/32.png) [@BCEats](https://forum.sambapos.com/u/BCEats)\
**Post date:** [September 19, 2020, 4:00am UTC](https://forum.sambapos.com/t/sorting-tasks-switching-task-position/22961/5 "2020-09-19T04:00:48Z")

</div>

I am building a KDS with tasks, and would like to switch the order that Tasks/Orders are displayed.

Backstory:  
we get quite a few customers come where they come in and are like “WE WANT IT IN A RUSH” so then we input the order, but then the order is displayed at the very back of the KDS, which makes the chefs lose time. I would like to remedy this by moving the order to the #1 position on the KDS.

So position 4 will be put to position 1, or 2(or where ever we want to put it)

 ![image](https://forum.sambapos.com/uploads/default/original/3X/b/1/b1a214cecbd5b10e4c1f28e39ad8488eee1562a2.png)

I’m working on a bump bar system like the one that QMckay did here:

> [@Bump Bar for Kitchen display](https://forum.sambapos.com/t/bump-bar-for-kitchen-display/9899/52):
>
> @emre, I am working on this idea for a Recall List … [image] The Up/Down arrows track position number, and I use ToggleIf to select the appropriate position … But if we currently have position #1 selected and we click the up arrow, I cannot figure a way to “deselect” card number 1. EDIT: Never-mind - sorted that ^ out - just Refresh the Entity Screen! I don’t really know how many positions are in the Widget, so I don’t know how to constrain the Max position number to stop at the l…

But there will be a switch button, where if you press that, and press 7, then 1, it’ll move position #7 in front of #1.

---

<div class="post-metadata">

**Author:** ![Bob\_be](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@Bob\_be](https://forum.sambapos.com/u/Bob_be)\
**Post date:** [September 19, 2020, 4:25am UTC](https://forum.sambapos.com/t/sorting-tasks-switching-task-position/22961/6 "2020-09-19T04:25:37Z")

</div>

Ok. How are the tasks sorted now…from your image it looks like 15, 16, 17,18 & 19. Is this how they are sorted? Are these custom field numbers?

You might have to re-assign numbers. If a new order came in, you wouldn’t want to swap it for the first position (the first becomes last and last becomes first). I think you would want to bump everything down.

You could maybe assign a letter after the number, but that might only get you as close as the 2nd position. (I haven’t tried it, just guessing)

---

<div class="post-metadata">

**Author:** ![BCEats](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/b/4491bb/32.png) [@BCEats](https://forum.sambapos.com/u/BCEats)\
**Post date:** [September 19, 2020, 10:25pm UTC](https://forum.sambapos.com/t/sorting-tasks-switching-task-position/22961/7 "2020-09-19T22:25:06Z")

</div>

Ah Sorry Bob, the screen shot was just an example, the screen shot is of a Ticket Lister, not a Task Editor.

The Task Editor I found sorts by the End Date Field(Unless there is a way to specify what to sort by?)

---

<div class="post-metadata">

**Author:** ![Bob\_be](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@Bob\_be](https://forum.sambapos.com/u/Bob_be)\
**Post date:** [September 20, 2020, 12:16am UTC](https://forum.sambapos.com/t/sorting-tasks-switching-task-position/22961/8 "2020-09-20T00:16:20Z")

</div>

I did a little testing, with no success. I thought this would display the date and time, but it doesn’t.

```auto
{REPORT OPEN TASK DETAILS:T.EndDate:(TST=<task name>) && T.Identifier="<identifier>":[=FD('{0}','yyyy/MM/dd hh\:mm\:ss')]}

```

It just reports back `09/07/2020 12:00:00` (a random task I have with a date).

---

<div class="post-metadata">

**Author:** ![BCEats](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/b/4491bb/32.png) [@BCEats](https://forum.sambapos.com/u/BCEats)\
**Post date:** [September 20, 2020, 12:26am UTC](https://forum.sambapos.com/t/sorting-tasks-switching-task-position/22961/9 "2020-09-20T00:26:51Z")

</div>

Is that the date/time that is saved in the database?

---

<div class="post-metadata">

**Author:** ![Bob\_be](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@Bob\_be](https://forum.sambapos.com/u/Bob_be)\
**Post date:** [September 20, 2020, 12:33am UTC](https://forum.sambapos.com/t/sorting-tasks-switching-task-position/22961/10 "2020-09-20T00:33:17Z")

</div>

That’s what I was thinking, but its not pulling it up like I thought it would. Maybe an sql report might do it.

---

<div class="post-metadata">

**Author:** ![BCEats](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/b/4491bb/32.png) [@BCEats](https://forum.sambapos.com/u/BCEats)\
**Post date:** [September 20, 2020, 3:31am UTC](https://forum.sambapos.com/t/sorting-tasks-switching-task-position/22961/11 "2020-09-20T03:31:17Z")

</div>

Hmmm, playing around with sql requests, and still can’t figure out the milliseconds, I’m going to move this to another thread, because I did sort of figure out the original question.

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![Francisco\_Lopez](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/f/3bc359/32.png) [@Francisco\_Lopez](https://forum.sambapos.com/u/Francisco_Lopez)\
**Post date:** [September 20, 2020, 4:05am UTC](https://forum.sambapos.com/t/sorting-tasks-switching-task-position/22961/12 "2020-09-20T04:05:52Z")

</div>

have you tried with using `format(EndDate,'yyyy-MM-ddTHH:mm:ss.fff')` in the sql query?

---

<div class="post-metadata">

**Author:** ![BCEats](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/b/4491bb/32.png) [@BCEats](https://forum.sambapos.com/u/BCEats)\
**Post date:** [September 20, 2020, 8:06am UTC](https://forum.sambapos.com/t/sorting-tasks-switching-task-position/22961/13 "2020-09-20T08:06:06Z")

</div>

YES!!!

Thank you so much! I was doing the formatting after the query(as a string) in the script.
