ruby, two solutions
First, short and simple\n\nRebuild the strings one char at a time, ensuring the new strings remain sorted. Eventually take the difference of size from an origin
# First, short and simple\n\nRebuild the strings one char at a time, ensuring the new strings remain sorted. Eventually take the difference of size from an original string to a new string. (The first of each, but they\'re all the same size.)\n\nThis creates new strings and arrays at each char column, and compares the whole incremental strings at each step, so a bit wasteful.\n\n### Code\n\n```ruby\ndef min_deletion_size(ss)\n  ss[0].size -\n  ss.map(&:chars).transpose.inject(ss.size.times.map{""}) do |a,cs|\n    a.zip(cs).map(&:join).then{|b|b.sort == b ? b : a }\n  end[0].size\nend\n```\n\n# Second, slightly faster\n\nThis only compares each char pair once. Requires a bit of longer explanation tho.\n\nGiven the strings `ss=["zxgaz","rxfbz","syfaz"]`\n\nMake a table `m` comparing each char to the one below it:\n```\nss[0]:  z  x  g  a  z\n m[0]:  1  0  1 -1  0\nss[1]:  r  x  f  b  z\n m[1]: -1 -1  0  1  0\nss[2]:  s  y  f  a  z\n```\n\nThe comparison is using `<=>`, so `-1 = a<b`, `0 = a==b`, `1 = a>b`.\n\n\nKeep dropping the first column while it contains `1`, as that means it\'s keeping the list unsorted. These are the deletions we\'re counting for the answer.\n\n```text\ndrop & count 1 deletion\n \u25BC\n 1  0  1 -1  0\n-1 -1  0  1  0\n```\n\nWith no leading `1`s left, we look for rows starting with with `-1`. These are unambiguously sorted, so we don\'t need to look at them anymore, we drop them:\n\n```text\n        0  1 -1  0\ndrop \u25BA -1  0  1  0\n```\n\nWe now have only `0`s left in the first column, which means equal chars, so we need to look at the next column. Drop the front column and loop again:\n\n```text\ndrop\n\u25BC \n0  1 -1  0\n```\n\nKeep looping until the matrix is empty. Return the count.\n\n### Code\n\n```ruby\n# a tiny helper class to clarify the matrix operations\nclass Matrix < Array\n  def cshift        = each{|row| row.delete_at 0 } # drops first column\n  def cmember?(i,x) = any?{|row| row[i] == x }     # column i contains x\nend\n\ndef min_deletion_size(ss)\n  n, m = 0, Matrix[*ss.map(&:bytes).transpose\n            .map{|cs| cs.each_cons(2).map{_1<=>_2} }.transpose]\n\n  while m.dig(0,0) # fast way to check if not empty\n    next (m.cshift; n+=1) if m.cmember? 0, 1 # del col 0 while it breaks sorting (contains 1)\n    m.reject!{|head,*| head == -1 }          # drop rows already deemed sorted (start with -1)\n    m.cshift                                 # drop col 0, need to look at next col (only 0s left)\n  end\n  return n\nend\n```
['Ruby']