Splunk Search

How to sort my table columns?

vnithin123
Engager

Can someone help in sorting table columns. Table contains
Row1,Row2,Row3,Row11,Row22,Row33
I tried sorting in order. but it shows below

Row1
Row11
Row2
Row22
Row3
Row33

Result should be -
Row1
Row2
Row3
Row11
Row22
Row33

Thanks

Tags (3)
0 Karma
1 Solution

gvmorley
Contributor

Hi,

One way you could sort this, would be to extract the number from the field containing "Row" and then sort by that number.

For example, assuming your "Row" field is called "row_no":

| rex field="row_no" "Row(?<row_sort>\d+)"
| sort + row_sort

If you didn't want the "sort" field afterwards, you could then remove it with:

| fields - row_sort

To see a full example, try this:

| makeresults
| fields - _time
| eval row_no=mvrange(1,34) | mvexpand row_no | eval row_no="Row".row_no
| rex field="row_no" "Row(?<row_sort>\d+)"
| sort + row_sort

Hopefully that will get you the result that you're looking for.

View solution in original post

gvmorley
Contributor

Hi,

One way you could sort this, would be to extract the number from the field containing "Row" and then sort by that number.

For example, assuming your "Row" field is called "row_no":

| rex field="row_no" "Row(?<row_sort>\d+)"
| sort + row_sort

If you didn't want the "sort" field afterwards, you could then remove it with:

| fields - row_sort

To see a full example, try this:

| makeresults
| fields - _time
| eval row_no=mvrange(1,34) | mvexpand row_no | eval row_no="Row".row_no
| rex field="row_no" "Row(?<row_sort>\d+)"
| sort + row_sort

Hopefully that will get you the result that you're looking for.

jlvix1
Communicator

What is your query?

0 Karma
Get Updates on the Splunk Community!

Splunk Observability Cloud’s AI Assistant in Action Series: Analyzing and ...

This is the second post in our Splunk Observability Cloud’s AI Assistant in Action series, in which we look at ...

Elevate Your Organization with Splunk’s Next Platform Evolution

 Thursday, July 10, 2025  |  11AM PDT / 2PM EDT Whether you're managing complex deployments or looking to ...

Splunk Answers Content Calendar, June Edition

Get ready for this week’s post dedicated to Splunk Dashboards! We're celebrating the power of community by ...