# Return a Sorted List with a Wildcard Character

**URL:** <https://forum.inductiveautomation.com/t/return-a-sorted-list-with-a-wildcard-character/7580>\
**Category:** Ignition\
**Created:** [November 18, 2013, 4:23pm UTC](https://forum.inductiveautomation.com/t/return-a-sorted-list-with-a-wildcard-character/7580 "2013-11-18T16:23:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhastie](https://avatars.discourse-cdn.com/v4/letter/b/d6d6ee/32.png) [@bhastie](https://forum.inductiveautomation.com/u/bhastie)\
**Post date:** [November 18, 2013, 4:23pm UTC](https://forum.inductiveautomation.com/t/return-a-sorted-list-with-a-wildcard-character/7580/1 "2013-11-18T16:23:32Z")

</div>

I want to return a sorted list of the lines in a particular facility. I want the list to be sorted by line number in ascending order but I want an ‘\*’ at the top to indicate a wildcard or Select All. Currently, I have the following on a drop down box:

```auto
Select 
	'*' as Line
FROM 
	Equipment  
UNION

SELECT 
	ltrim(str(Line))
FROM 
	Equipment 
WHERE 
	Location = '{Root Container.Loc}'
```

This is fine except it sorts the list as strings so Line 10 appears between Line 1 and Line 2.

Anyone done this before or have any ideas??

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [November 18, 2013, 4:36pm UTC](https://forum.inductiveautomation.com/t/return-a-sorted-list-with-a-wildcard-character/7580/2 "2013-11-18T16:36:49Z")

</div>

I have done this sort of thing before.  
Try something like this:

```auto
SELECT t.Line
FROM
   (Select
      '*' as Line, 1 as SortOrder
   FROM
      Equipment 
   UNION
   SELECT
      ltrim(str(Line)), 2 as SortOrder
   FROM
      Equipment
   WHERE
      Location = '{Root Container.Loc}') t
ORDER BY
   t.SortOrder, t.Line
```
