Question: Due to some odd reason, I cannot go with JPA vendor like Hibernate, etc and **I must use MyBatis.** 

Is there any implementation where we can enrich similar facility of CRUD operation in Mybatis?  

(Like GenericDAO save, persist, merge, etc)

I have managed to come up with single interface implementation of CRUD type of operations (like Generic DAO) but still each table has to write it's own query in XML file (as table name, column names are different).

Will that make sense to come up with generic implementation?  

Where I can give any table object for any CRUD operation through only 4 XML queries. (insert, update, read, delete) passing arguments of table name, column names, column values..etc.

Does it look like re-inventing the wheel in MyBatis or does MyBatis has some similar support?

Answer: 
The idea is still the same. Just that you will be looking for a specific attribute in the class object. 

For your card class, you could do something like this:

```
hand = [ Card(10, 'H'), Card(2,'h'), Card(12,'h'), Card(13, 'h'), Card(14, 'h') ]

```

Then you could do

```
sorted_cards = sorted(hand, key=lambda x: x.rank)

```

The output looks something like this:

```
>>> [card.number for card in sorted_cards]
[2, 10, 12, 13, 14]

```
This is the object-oriented approach. At a minimum, you should specify `__eq__` and `__lt__` operations for this to work. Then just use `sorted(hand)`.

```
class Card(object):

    def __init__(self, rank, suit):
        self.rank = rank
        self.suit = suit

    def __eq__(self, other):
        return self.rank == other.rank and self.suit == other.suit

    def __lt__(self, other):
        return self.rank < other.rank

hand = [Card(10, 'H'), Card(2, 'h'), Card(12, 'h'), Card(13, 'h'), Card(14, 'h')]
hand_order = [c.rank for c in hand]  # [10, 2, 12, 13, 14]

hand_sorted = sorted(hand)
hand_sorted_order = [c.rank for c in hand_sorted]  # [2, 10, 12, 13, 14]

```

It's good practice to make object sorting logic, if applicable, a property of the class rather than incorporated in each instance the ordering is required. This way you can just call `sorted(list_of_objects)` each time.