Python 3, one line
Explanation\n\n1. Shift to right:\n\t1. Split by \'*\'\n\t2. For each part, count . and # and put . on left and and # on right\n\t3. Join again by *\n2. Rotate 
# Explanation\n\n1. Shift to right:\n\t1. Split by `\'*\'`\n\t2. For each part, count `.` and `#` and put `.` on left and and `#` on right\n\t3. Join again by `*`\n2. Rotate 90 degrees\n\t1. Reverse rows\n\t2. Invert with `zip(*rows)`\n\nTime: `O(n)`\nSpace: `O(n)` for the rotating\n\n# One line\n\n```python\nclass Solution:\n  def rotateTheBox(self, box: List[List[str]]) -> List[List[str]]:\n    return zip(*[\'*\'.join(\'\'.join(c * p.count(c) for c in \'.#\') for p in \'\'.join(row).split(\'*\')) for row in box][::-1])\n```\n\n# A little shorter, but a little slower\n\nUsing sort instead of counting to do the shifting. Runtime is about 50% longer.\n\nTime: `O(n log(n))`\nSpace: `O(n)` for the rotating\n\n```python\nclass Solution:\n  def rotateTheBox(self, box: List[List[str]]) -> List[List[str]]:\n    return zip(*[\'*\'.join(\'\'.join(sorted(p)[::-1]) for p in \'\'.join(row).split(\'*\')) for row in box][::-1])\n```
[]