Given an array A of N lowercase letter strings of the same length. The task is to find the count of columns that are not sorted in increasing order.

**Examples:**

Input:A = ["cba", "dah", "ghi"]Output:1 2nd Column ["b", "a", "h"] is not sorted in increasing order.Input:A = ["zyx", "wvu", "tsr"]Output:3 All columns are not sorted in increasing order.

**Approach:** Traverse each column one by one and check if the next element is greater than the previous element in the same column. If not the increment the **countOfCol** by 1 and keep traversing till all the columns get traversed. Print the value of **countOfCol**.

`# function to count the unsorted columns ` `def` `countUnsorted(A): ` ` ` ` ` `countOfCol ` `=` `0` ` ` ` ` `for` `col ` `in` `zip` `(` `*` `A): ` ` ` `if` `any` `(col[i] > col[i ` `+` `1` `] ` `for` `i ` `in` `range` `(` `len` `(col) ` `-` `1` `)): ` ` ` `countOfCol ` `+` `=` `1` ` ` ` ` `return` `countOfCol ` ` ` `# Driver code ` `A ` `=` `[` `"cba"` `, ` `"daf"` `, ` `"ghi"` `] ` `print` `(countUnsorted(A)) ` |

*chevron_right*

*filter_none*

**Output:**

1

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Sort even and odd placed elements in increasing order
- Python | Get items in sorted order from given dictionary
- Python - Sorted order Dictionary items pairing
- Python | Inserting item in sorted list maintaining order
- Python | List Element Count with Order
- Count of binary strings of length N having equal count of 0's and 1's and count of 1's ≥ count of 0's in each prefix substring
- Sum of columns of a 2-D Matrix where first element is odd
- Python - Custom Columns Matrix
- Python - Summation Matrix columns
- Python | Minimum Difference in Matrix Columns
- Python - Tuple Matrix Columns Summation
- Python | Cummulative Columns summation of Records
- Print all Increasing Subsequence of a List
- Python - List of N size increasing lists
- Python | Check if list is strictly increasing
- Python program for Longest Increasing Subsequence
- Python | Increasing alternate element pattern in list
- Python | Find groups of strictly increasing numbers in a list
- Python | Reverse sequence of strictly increasing integers in a list
- Python | Combining two sorted lists

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.