Add example of `__gt__` function.
PiperOrigin-RevId: 307504548
Change-Id: Idc009e5ba5a35c5a140c6b1063748ee4fbb923a2
diff --git a/tensorflow/python/feature_column/feature_column.py b/tensorflow/python/feature_column/feature_column.py
index f538253..87420d0 100644
--- a/tensorflow/python/feature_column/feature_column.py
+++ b/tensorflow/python/feature_column/feature_column.py
@@ -1797,7 +1797,26 @@
`__gt__` is called when the "other" object being compared during the sort
does not have `__lt__` defined.
- Example: http://gpaste/4803354716798976
+ Example:
+ ```
+ # __lt__ only class
+ class A():
+ def __lt__(self, other): return str(self) < str(other)
+
+ a = A()
+ a < "b" # True
+ "0" < a # Error
+
+ # __lt__ and __gt__ class
+ class B():
+ def __lt__(self, other): return str(self) < str(other)
+ def __gt__(self, other): return str(self) > str(other)
+
+ b = B()
+ b < "c" # True
+ "0" < b # True
+ ```
+
Args:
other: The other object to compare to.
diff --git a/tensorflow/python/feature_column/feature_column_v2.py b/tensorflow/python/feature_column/feature_column_v2.py
index ab9866b..9e7df66 100644
--- a/tensorflow/python/feature_column/feature_column_v2.py
+++ b/tensorflow/python/feature_column/feature_column_v2.py
@@ -2254,7 +2254,25 @@
`__gt__` is called when the "other" object being compared during the sort
does not have `__lt__` defined.
- Example: http://gpaste/4803354716798976
+ Example:
+ ```
+ # __lt__ only class
+ class A():
+ def __lt__(self, other): return str(self) < str(other)
+
+ a = A()
+ a < "b" # True
+ "0" < a # Error
+
+ # __lt__ and __gt__ class
+ class B():
+ def __lt__(self, other): return str(self) < str(other)
+ def __gt__(self, other): return str(self) > str(other)
+
+ b = B()
+ b < "c" # True
+ "0" < b # True
+ ```
Args:
other: The other object to compare to.