I presume you have read the documentation for TreeSet; you must either pass an object implementing Comparable<T> or you must pass a Comparator<T> as a separate argument (I think to the constructor).
No, that is not the right way to use a Comparator. Create it in a different class, as an anonymous class, or as a λ. You might do well to change your class to implement the Comparable<T> interface, which is probably the easiest solution at present.
Why is your class called person if it has a salary field and an id field? Surely you have written an Employee class there?
BTW, it makes no sense for Person to implement Comparator<Person>. Comparators should be separate entities because they are like a third party arbiter, taking two Person objects and evaluating how they compare to each other. It may make sense in the real world that every Person could potentially serve in that capacity (that's why we have judges and juries, after all) but in an object-oriented programming context, it doesn't. That's just going to be confusing. Look for examples of how to write a Comparator
The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable.—Kent Beck