# Sorting not working in frontend-config

**URL:** <https://forum.canton.network/t/sorting-not-working-in-frontend-config/2979>\
**Category:** App Development\
**Created:** [August 11, 2021, 12:50pm UTC](https://forum.canton.network/t/sorting-not-working-in-frontend-config/2979 "2021-08-11T12:50:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cagrawal](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@cagrawal](https://forum.canton.network/u/cagrawal)\
**Post date:** [August 11, 2021, 12:50pm UTC](https://forum.canton.network/t/sorting-not-working-in-frontend-config/2979/1 "2021-08-11T12:50:09Z")

</div>

Hi,

Sorting is not working for me in frontend-config.  
I want to sort on Advice # which is a integer type column and using the following:

```haskell
tradeAdvice: {
    type: "table-view",
    title: "Trade Advice",
    source: {
      type: "contracts",
      filter: [
             ],
      search: "",
      sort: [
        {
          field: "id",
          direction: "DESCENDING"
        }
      ]
    },
    columns: [
      {
        key: "id",
        title: "Advice #",
        createCell: ({rowData}) => ({type: "text", value: DamlLfValue.toJSON(rowData.argument).adviceNumber}),
        sortable: true,
        width: 20,
        weight: 0,
        alignment: "left"
      },

```

Can you please advise what I may be doing wrong?

Thanks in advance.  
Chandan

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [August 11, 2021, 7:34pm UTC](https://forum.canton.network/t/sorting-not-working-in-frontend-config/2979/2 "2021-08-11T19:34:07Z")

</div>

`field: "id"` will sort by the contract id. Based on what you’re displaying in the `columns` section it looks like you want to sort on a field called `adviceNumber`. You can do that with `field: "argument.adviceNumber"` where `argument` matches on the actual contract payload. The full frontend config then looks something like this

```haskell
trade_advice: {
      type: "table-view",
      title: "Trade Advice",
      source: {
        type: "contracts",
        filter: [
               ],
        search: "",
        sort: [
          {
            field: "argument.adviceNumber",
            direction: "DESCENDING"
          }
        ]
      },
      columns: [
        {
          key: "id",
          title: "Advice #",
          createCell: ({rowData}) => ({type: "text", value: DamlLfValue.toJSON(rowData.argument).adviceNumber}),
          sortable: true,
          width: 20,
          weight: 0,
          alignment: "left"
        },
      ]
  }

```

credit to @Robert_Autenrieth for figuring this out

---

<div class="post-metadata">

**Author:** ![cagrawal](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@cagrawal](https://forum.canton.network/u/cagrawal)\
**Post date:** [August 11, 2021, 8:43pm UTC](https://forum.canton.network/t/sorting-not-working-in-frontend-config/2979/3 "2021-08-11T20:43:34Z")

</div>

HI,

Yes, you are right, I want to sort on AdviceNumber.

I tried this but still does not work. Please help me. This is what my complete js file looks like:

```haskell
import { DamlLfValue } from '@da/ui-core';

export const version = {

  schema: 'navigator-config',

  major: 2,

  minor: 0,

};

export const customViews = (userId, party, role) => ({

  tradeAdvice: {

    type: "table-view",

    title: "Trade Advice",

    source: {

      type: "contracts",

      filter: [  

      ],

      search: "",

      sort: [

        {

          field: "arguement.adviceNumber",

          direction: "DESCENDING"

        }

      ]

    },

    columns: [

      {

        key: "id",

        title: "Advice #",

        createCell: ({rowData}) => ({type: "text", value: DamlLfValue.toJSON(rowData.argument).adviceNumber}),

        sortable: true,

        width: 20,

        weight: 0,

        alignment: "left"

      },

      {

        key: "tradeNumber",

        title: "#",

        createCell: ({rowData}) => ({type: "text", value: DamlLfValue.toJSON(rowData.argument).tradeNumber}),

        sortable: true,

        width: 10,

        weight: 0,

        alignment: "left"

      },

      {

        key: "tradeTime",

        title: "Time",

        createCell: ({rowData}) => ({type: "text", value: DamlLfValue.toJSON(rowData.argument).tradeTime}),

        sortable: true,

        width: 60,

        weight: 0,

        alignment: "left"

      },

      {

        key: "tradeTimeMS",

        title: "Time (ms)",

        createCell: ({rowData}) => ({type: "text", value: DamlLfValue.toJSON(rowData.argument).tradeTimeMS}),

        sortable: true,

        width: 80,

        weight: 0,

        alignment: "left"

      },

      {

        key: "tradeSide",

        title: "Side",

        createCell: ({rowData}) => ({type: "text", value: DamlLfValue.toJSON(rowData.argument).tradeSide}),

        sortable: true,

        width: 10,

        weight: 0,

        alignment: "left"

      },

      {

        key: "tradeQuantity",

        title: "Quantity",

        createCell: ({rowData}) => ({type: "text", value: DamlLfValue.toJSON(rowData.argument).tradeQuantity}),

        sortable: true,

        width: 10,

        weight: 0,

        alignment: "right"

      },

      {

        key: "tradePrice",

        title: "Price",

        createCell: ({rowData}) => ({type: "text", value: wrapInBrackets(DamlLfValue.toJSON(rowData.argument).tradePrice, '$')}),

        sortable: true,

        width: 10,

        weight: 0,

        alignment: "right"

      },

      {

        key: "pnl",

        title: "This PNL",

        createCell: ({rowData}) => ({type: "text", value: wrapInBrackets(DamlLfValue.toJSON(rowData.argument).pnl, '$')}),

        sortable: true,

        width: 10,

        weight: 0,

        alignment: "right"

      },

      {

        key: "cumulativePNL",

        title: "Cumulative PNL",

        createCell: ({rowData}) => ({type: "text", value: wrapInBrackets(DamlLfValue.toJSON(rowData.argument).cumulativePNL, '$')}),

        sortable: true,

        width: 20,

        weight: 0,

        alignment: "right"

      }

    ]

  }

})

function makeTwice(input)

{

  return input + input;

}

//fucntion 

function wrapInBrackets(value, symbol)

{

  //alert()

  var absValue = Math.abs(value);

  var returnString = new Intl.NumberFormat('en-US', { minimumFractionDigits: 4 }).format(absValue);

  return symbol + (value < 0 ? '(' + returnString + ')' : returnString);

}

```

---

<div class="post-metadata">

**Author:** ![Robert\_Autenrieth](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/robert_autenrieth/32/153_2.png) [@Robert\_Autenrieth](https://forum.canton.network/u/Robert_Autenrieth)\
**Post date:** [August 12, 2021, 11:56am UTC](https://forum.canton.network/t/sorting-not-working-in-frontend-config/2979/4 "2021-08-12T11:56:12Z")

</div>

> [@cagrawal](#):
>
> `field: "arguement.adviceNumber",`

You have a typo in this line. It should be `argument` instead of `arguement`. Can you please try again after fixing the typo?
