BFS is simpler for this question. I provide a DFS solution here.

Use the height and insert orders as the key for sorting the queue.

```
public class Solution {
class Ele implements Comparable<Ele>{
int val;
int h;
int order;
Ele(int val, int h, int order){
this.val = val;
this.h = h;
this.order = order;
}
public int compareTo(Ele other){
if(this.h == other.h){
return Integer.compare(this.order, other.order);
}
return Integer.compare(this.h, other.h);
}
}
public List<List<Integer>> verticalOrder(TreeNode root) {
List<List<Integer>> res = new ArrayList<List<Integer>>();
if(root == null)return res;
Map<Integer, PriorityQueue<Ele>> map = new TreeMap<>();
preOrder(root, map, 0, 0);
for(Integer key:map.keySet()){
PriorityQueue<Ele> tmp = map.get(key);
List<Integer> tmpList = new ArrayList<Integer>();
while(!tmp.isEmpty()){
tmpList.add(tmp.poll().val);
}
res.add(tmpList);
}
return res;
}
public void preOrder(TreeNode root, Map<Integer, PriorityQueue<Ele>> map, int key, int height){
if(root == null)return;
if(map.containsKey(key)){
PriorityQueue<Ele> tmp = map.get(key);
tmp.add(new Ele(root.val,height,tmp.size()));
}else{
PriorityQueue<Ele> tmp = new PriorityQueue<Ele>();
tmp.add(new Ele(root.val,height,1));
map.put(key, tmp);
}
preOrder(root.left, map, key-1, height+1);
preOrder(root.right, map, key+1, height+1);
}
}
```