# Beginners question re sorting

**URL:** <https://forum.servoy.com/t/beginners-question-re-sorting/15505>\
**Category:** Classic Servoy\
**Created:** [February 14, 2012, 8:07am UTC](https://forum.servoy.com/t/beginners-question-re-sorting/15505 "2012-02-14T08:07:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![caroline.j](https://avatars.discourse-cdn.com/v4/letter/c/ed655f/32.png) [@caroline.j](https://forum.servoy.com/u/caroline.j)\
**Post date:** [February 14, 2012, 8:07am UTC](https://forum.servoy.com/t/beginners-question-re-sorting/15505/1 "2012-02-14T08:07:13Z")

</div>

Sorry this will seem very basic but could someone point me in the correct direction.

In FoxPro you can setup a number of indexes that can also have functions within them and then elect to order the table by that order, I’m unsure how to achieve the same within a Servoy Form.

At it’s most basic level all I’m trying to achieve is a form with a table view of some descriptions but for the order to ignore the texts case (ie order in Lower Case)

```auto
Currently:
    This is a description
    another description

What I want:
    another description
    This is a description

```

Thanks in anticipation.  
Caroline

---

<div class="post-metadata">

**Author:** ![jcarlos](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jcarlos](https://forum.servoy.com/u/jcarlos)\
**Post date:** [February 14, 2012, 2:54pm UTC](https://forum.servoy.com/t/beginners-question-re-sorting/15505/2 "2012-02-14T14:54:16Z")

</div>

Caroline,

I think that’s a database thing. Servoy will sort the table in the way the collation is defined in the database. You need to define the collation type in the database.

When you create a table, you can tell the database to ignore the texts case (define the collation). In MySQL you can do this:

```auto
CREATE TABLE test.test (
   tablename_id INT,
   tablecolumn VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci
) ENGINE = InnoDB ROW_FORMAT = DEFAULT;

```

Note the **\_ci** in the **COLLATE** statement. This does the trick. \_ci (is case insensitive), \_cs (is case sensitive), or \_bin (is binary).

I put your example string in a solution I’m building, and this how it looks:

[attachment=1]Capture.GIF[/attachment]  
[attachment=0]Capture2.GIF[/attachment]  
Hope this help.

JC

 ![Capture2.GIF](https://canada1.discourse-cdn.com/flex010/uploads/servoy/original/2X/3/38f889ed871a935e3c4b2c6b66d3c8a87ce1c953.gif)

 ![Capture.GIF](https://canada1.discourse-cdn.com/flex010/uploads/servoy/original/2X/9/9a041431f3794150789fce180b6ff2955525ed17.gif)

---

<div class="post-metadata">

**Author:** ![caroline.j](https://avatars.discourse-cdn.com/v4/letter/c/ed655f/32.png) [@caroline.j](https://forum.servoy.com/u/caroline.j)\
**Post date:** [February 14, 2012, 5:37pm UTC](https://forum.servoy.com/t/beginners-question-re-sorting/15505/3 "2012-02-14T17:37:00Z")

</div>

Many thanks JC I’ll give that a go.

---

<div class="post-metadata">

**Author:** ![caroline.j](https://avatars.discourse-cdn.com/v4/letter/c/ed655f/32.png) [@caroline.j](https://forum.servoy.com/u/caroline.j)\
**Post date:** [February 15, 2012, 5:23pm UTC](https://forum.servoy.com/t/beginners-question-re-sorting/15505/4 "2012-02-15T17:23:19Z")

</div>

Does anyone know if the collate sequence can be set after a table has been created or if case insensitive can be set for a sort??

---

<div class="post-metadata">

**Author:** ![jcarlos](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jcarlos](https://forum.servoy.com/u/jcarlos)\
**Post date:** [February 17, 2012, 2:48am UTC](https://forum.servoy.com/t/beginners-question-re-sorting/15505/5 "2012-02-17T02:48:33Z")

</div>

You should be able to change the collation of a table. In MySQL is something like this:

```auto
ALTER TABLE database.table CHARACTER SET latin1 COLLATE latin1_general_ci;

```

Or

```auto
ALTER TABLE database.M-to-M_table CHARACTER SET utf8 COLLATE utf8_general_ci,
 DROP FOREIGN KEY M-to-M_table_ref01,
 DROP FOREIGN KEY M-to-M_table_ref02;
ALTER TABLE database.M-to-M_table
 ADD CONSTRAINT M-to-M_table_ref01 FOREIGN KEY (table1_id) REFERENCES database.table1 (table1_id) ON UPDATE RESTRICT ON DELETE RESTRICT,
 ADD CONSTRAINT M-to-M_table_ref02 FOREIGN KEY (table2_id) REFERENCES database.table2 (table2_id) ON UPDATE RESTRICT ON DELETE RESTRICT;

```

If you have problems changing the table collation because of indexes’ or keys’ constraints (but you should not), you always can change the collation of the column that you need to sort.

Hope this help. JC
